#help-development
1 messages · Page 309 of 1
so if I want to make a custom messaging channel, I need to register it using bungeecord plugin right?
yes
you will need the bungee plugin to intercept the incoming messages
and do whatever you want with them
whether it may be to send the messages to other servers etc
Or you can just use Forward in the bungee messaging channel so you dont have to do all of that
is there any official wiki for that? 👀
I have many custom data & want to use own messaging channel
You should probably use redis then
is it for a public plugin or a private one?
public plugin. but want it without database
I already have database. but also want to transfer data with bungee
but then they'll have to install a plugin in the bungee server AND spigot server
no prob with that.
if you're okay with that then you can use custom channels
but it'll still need a database?
uhh. can I just look at an example, of how it works?
alright, I will try to find it out
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@warm light
also remember plugin messages require a player to be online to be sent since it's sent via a player's connection
yes
ahh
redis
Hello, I'm doing a tops system, and I do a LIMIT 3 that returns a UUID, how can I get the name with that uuid, I already tried with Bukkit.getPlayer(uuid).getName();
but this get error Null
and the uuid is not null
how do I check if a player is an operator
player.isOp();
thx
Your uuid is a string not a UUID so that method is trying to get the offline player with the name of the uuid
Check the UUID class for the method to convert it
Ye
show your TopManager class
whatever is in line 140, something there's null
?paste <---
paperspigot 1.8.8
smh....
hello,
so i have a command where when you type '/roleplayitems check' it checks to see if the item in the hand has a specific key or not, then displays whether or not it is a roleplay item.
problem is if the player isn't holding anything. i thought i checked for it, but it still seems to be giving me errors when the item is null.
CODE:
if (args[0].equalsIgnoreCase("check") && args.length == 1){
ItemStack itemHand = player.getEquipment().getItemInMainHand();
if (itemHand.getType() != null) {
NamespacedKey key = new NamespacedKey(RoleplayItems.getPlugin(), "rp-Item");
ItemMeta itemMeta = itemHand.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if (container.has(key, PersistentDataType.DOUBLE)) {
player.sendMessage("Item is a RoleplayItem");
return true;
} else {
player.sendMessage("Item is NOT a RoleplayItem");
return true;
}
} else {
player.sendMessage(ChatColor.DARK_RED + "Hold an item.");
return false;
}
ERRORS:
?paste the error dont screenshot it
use getInventory not getEquipment
still same error
?paste the full onCommand method
the item doesnt have any extra meta im guessing so you probably want to check for that
what do you mean by this
i'm already checking for if it has a specific key or not
its just when i don't have an item in my hand
yeah
the item you have in your hand has no item meta
if its empty
so the pdc container is null
maybe you need to check item.hasItemMeta() before using itemHand.getItemMeta() to ensure that item has ItemMeta
^^
that removes the error i guess but i also wanted to check items that have no meta too
if it has no meta it has no pdc
and i'm guessing thats whats causing the error
so no meta means not a RoleplayItem
if the rp item has pdc identifying it, yes
yeah, but thats for some reason not possible in the maven-jar-plugin, its only possible in the mave-compiler-plugin: https://i.postimg.cc/xd4rWGF5/image.png
but i fixed it by setting the language level up (idk if thats a good solution): https://i.postimg.cc/s26y3C1p/image.png
?paste your pom
<source> etc belongs into the compiler plugin's configuration, not the maven-jar-plugin's one
here you have the pom.xml
as said, the source and target has nothing to do with the maven-jar-plugin, but with the maven-compiler-plugin
the .jar plugin is just to "zip" your compiled classes into a .jar file
the compiler plugin is the only thing that cares about the language level
for some reason the jar plugin is not working :C
wdym with "not working"?
my commands aren't working ingame
what exactly is the problem?
bet its unrelated
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
any errors in console
nope it sais build succesfull
^
yeah do you need extra informations?
yes
^ this
i think we need code, errors or anything
ok wait
Compile log: https://paste.md-5.net/weqilibaxe.cs
NicknameCommand.java: https://paste.md-5.net/nizovoqoni.java
Main.java: https://paste.md-5.net/uwuzokixaq.java
I think thats enough isnt it
but not only the commands arent working, nothing of the plugin is working ingame
why are you using != on a string and == on a string
look on console when you restart for errors
ok wait
when i used the marven-compiler-plugin, everything worked fine, but with the marven-jar-plugin its not working anymore
i doubt the jar plugin does the same thing then
yes the maven-compiler-plugin exports my source code and the maven-jar-plugin exports my code as .jar file, and i need that right?
?paste your latest.log
your issue has NOTHING to do with maven
okay
anyway, line 12 in NicknameCommand is already wrong
when starting the server it sais: https://paste.md-5.net/mefetakafu.md
as Epic already said, you must not use != or == for strings
you didnt define that command in your plugin.yml
and stop comparing strings with != or ==, you must use equals()
if you need to chek if something isnt equal to that use !args[0].equals
i did:
name: KonerUtils
version: '${project.version}'
main: com.koner.konerutils.Main
api-version: 1.19
author: KonerDev
description: The official plugin of KonerCraft
commands:
nickname:
usage: /nick <NAME>
description: Change your name on the entire KonerCraft server
aliases: nick
how are you building
wdym?
This makes no sense. Your stacktrace doesnt match the code you sent
are pressing the hammer, pressing the green play button, pressing something on the maven panel
In the code you sent, the getCommand() is in line 11. In your stacktrace, getCommand() is in line 12
Hey,
I just recoded one of my old plugins and want to store in a yml file a list of costum objects. However, when I restart the server, it gives me the error that it can't find a constructor for the object.
Do any of you have any idea how I can fix this?
Error:
org.yaml.snakeyaml.constructor.ConstructorException: could not determine a constructor for the tag tag:yaml.org,2002:com.example.shops.utils.ShopItem
in 'reader', line 2, column 3:
- !!com.example.shops.utils.ShopItem
- stop your server
- do
mvn clean package - install the new plugin .jar
- start server again
- see if it works now. If not, send latest.log again
@tawdry parcel
you dont have a serialize or deserialize or have configuration serializable support
does "ShopItem" implement ConfigurationSeriazable?
please ?paste the FULL ShopItem class
please don't just paste parts of it, but the full class
?paste
ok
package com.example.shops.utils;
import org.bukkit.inventory.ItemStack;
public class ShopItem {
private ItemStack itemStack;
private double worth, cost;
public ShopItem(double cost, ItemStack itemStack, double worth){
this.itemStack = itemStack;
this.cost = cost;
this.worth = worth;
}
public ShopItem(ItemStack itemStack, double worth, double cost){
this.itemStack = itemStack;
this.cost = cost;
this.worth = worth;
}
public ItemStack getItemStack() {
return itemStack;
}
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
public double getWorth() {
return worth;
}
public void setWorth(double worth) {
this.worth = worth;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
}
if you save a custom object, that class must implement ConfigurationSerializtable
and have a deserialze method and serialize
is that right:
package com.koner.konerutils.nickname;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class NicknameCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
String nickname = !args[0].equals("delete") || !args[0].equals("") ? args[0] : player.getName();
player.setDisplayName(nickname);
player.setCustomName(nickname);
player.setPlayerListName(nickname);
player.sendMessage("Display Name: " + player.getDisplayName() + " Name: " + player.getName() + " Custom Name: " + player.getCustomName() + " PlayerListName: " + player.getPlayerListName());
return true;
}
}
good to know
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
it must have at least ONE of those methods
but how do I implemet this?
args[0] == null if you are checking if its null
I'll give you an example in 3 minutes
thx
you mean args[0].equals(null)?
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.
public class MySerializableObject implements ConfigurationSerializable {
private final String name;
private final int age;
public MySerializableObject(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public Map<String, Object> serialize() {
Map<String,Object> map = new HashMap<>();
map.put("name", name);
map.put("age", age);
return map;
}
public static MySerializableObject deserialize(Map<String, Object> map) {
return new MySerializableObject((String) map.get("name"), (int) map.get("age"));
}
}
all the things I marked in green MUST be there
oh okay but it sais: Condition 'args[0] == null' is always 'false' when reached
null check first
basically, to make something seriaziable, you need to have a method that turns your object into a Map<String,Object>, called "serialize()", and another static "deserialize" method that takes a Map<String,Object> and turns it back into your object.
lol it works but it doesnt make sense for me
ok, Thanks. I will try xD
it's all explained in the javadocs for ConfigurationSeriazable: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/configuration/serialization/ConfigurationSerializable.html (read the docs at the top)
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
lets say you want to check if something isnt null or equals something, you would want to know if its null first
if its null it cant be the 2nd option
yeah ^ or use Objects.equals(...)
oh okay this makes sense now
however you should only use Objects.equals(...) if you know why you cannot just use equals() on null references
if i use mvn clean package it sais Compilation failure in intellij
it will probably also tell you a bit more
no
wait i send you screenshot
yes, a screenshot would be helpful
that doesnt look like you using mvn clean package tbh
oh and btw, if you get verified, you can send screenshots directly here
yeah i do it after breakfast
?paste your full pom.xml, fellow german
i just looked at that log and thought its a good thing your here
yeah well the logs clearly says "Quelloption 5 wird nicht mehr unterstützt."
yeah, I see
it means something like source option 5 is no longer supported
no
okay so
intellij generated that for me
in your <properties> section, add this:
(1 sec)
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
like this (without the <jarLocation> thing)
or 16, been as your java version is 19
does that not actually do anything
did you generate the pom through this stupid "Minecraft Dev Plugin" for IntelliJ?
It's known to be a bit stupid and only fuck things up
the plugin is great if you set your own poms
lol to setup your own poms, you could just use maven archetypes
it easier imo
yeah as we see
this dude is struggling since half an hour to get it to work, I wouldnt really consider this to be "easier"
ive got my build.gradle default setup to have my own build file
and its easier
without it its pointless
the "minecraft dev plugin" is shit. it's a cheap version of maven's archetypes, except that it adds useless stuff and misses important things and doesnt have any useful config options
e.g. "wanna use NMS?"
and it causes crashes in IJ ultimate whenever there's an IDE update
I now tried this and the serialisation is working but the deserializing not.
I get this Error:
org.yaml.snakeyaml.error.YAMLException: Could not deserialize object
...
Caused by: java.lang.IllegalArgumentException: Specified class does not exist ('at.kessapps.shops.utils.ShopItem')
at org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(ConfigurationSerialization.java:197) ~[spigot-a
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("itemStack", itemStack);
map.put("cost", cost);
map.put("worth", worth);
return map;
}
public static ShopItem deserialize(Map<String, Object> map) {
return new ShopItem((ItemStack) map.get("itemStack"), (double) map.get("worth"), (double) map.get("cost"));
}```
pom files should only ever be generated through archetypes. I never understood why anyone would use any "pom generator" when maven already got a way more powerful templating engine builtin
show your full ShopItem class again, and also show your full config file please
it looks like you renamed the class or package at one time but are still using a config file where the class was called differently
Class:
package at.kessapps.shops.utils;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
public class ShopItem implements ConfigurationSerializable {
private ItemStack itemStack;
private double worth, cost;
public ShopItem(ItemStack itemStack, double worth, double cost){
this.itemStack = itemStack;
this.cost = cost;
this.worth = worth;
}
public ItemStack getItemStack() {
return itemStack;
}
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
public double getWorth() {
return worth;
}
public void setWorth(double worth) {
this.worth = worth;
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("itemStack", itemStack);
map.put("cost", cost);
map.put("worth", worth);
return map;
}
public static ShopItem deserialize(Map<String, Object> map) {
return new ShopItem((ItemStack) map.get("itemStack"), (double) map.get("worth"), (double) map.get("cost"));
}
}
YML File:
Items:
- ==: at.kessapps.shops.utils.ShopItem
itemStack:
==: org.bukkit.inventory.ItemStack
v: 3120
type: OAK_LOG
cost: 2.0
worth: 1.0
already know the issue
thats a list of items so im guessing you arent getting the item back just from Items not the list
I use it for the version for maven compiler source and target
So i dont have to change the number twice
what do you mean?
that's a custom property then
by itself, it doesnt do anything
Items is a list, im guessing you are just trying to get the item as if thats a config section
I get the error on reloading the server. I never try to get the items from the array
please ?paste your class files. we need to know what line 29 in ShopData is, and what Main line 28 is
if you just post it here, we have to count the line numbers manually, and nobody wants to do that
so please use ?paste
package at.kessapps.shops.utils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
public class ShopData {
private static File file;
private static YamlConfiguration status;
public ShopData(){
File dir = new File("./plugins/Shops/");
if (!dir.exists()){
dir.mkdirs();
}
file = new File(dir, "ShopData.yml");
if (!file.exists()){
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
status = YamlConfiguration.loadConfiguration(file);
}
public static boolean contains(String path){
return status.contains(path);
}
public static void set(String path, Object value) throws IOException {
status.set(path, value);
status.save(file);
}
public static Object get(String path){
if (!contains(path)){
return null;
}
return status.get(path);
}
public static Object getKeys(String path){
if (!contains(path)){
return null;
}
return status.getConfigurationSection(path).getKeys(false);
}
public static void delete(String path) throws IOException {
status.set(path, null);
status.save(file);
}
}
Ye
from what i remember the file doesnt start at ./plugins/ it starts in your plugins resource folder
an it also creates the file if does not exist
you didnt read the docs that I sent you twice already 😛
in your onEnable, you have to call ConfigurationSerializable.registerClass(ShopItem.class)
BEFORE you access your config
oh, sorry. I didn't see that
np, but next time when someone sends you docs, please read them 😄
it has no registerClass function.
sorry I typed it wrong
ConfigurationSerialization.registerClass(Class)
Serialization != Serializable
ConfigurationSerialization.registerClass(ShopItem.class)
that is working XD
yeah
call that in the first line in your onEnable()
this tells spigot on how to deserialize your object
I could make so much more money if I'd be working instead of being here 24/7 lmao
no problem!
you are not here 24/7
how do you know?
its more lik 18/7
im normally always here
other than when im sleeping
I never slept in the entire 27 years of my life
trust me, it's true, I said it on the internet
it's a bit harder. here's my first ILS landing which is indeed "autopilot is landing for you" https://www.youtube.com/watch?v=2NQGuJvSaxU&t=1s
ILS (engl. instrument landing system)
Unter Instrumentenflug (umgangssprachlich auch Blindflug) bezeichnet man das Steuern von Luftfahrzeugen, bei dem die Fluglage ohne Bezug auf äußere Anhaltspunkte mit Hilfe von Instrumenten an Bord gehalten wird (Ausnahme - der circling approach ist ein Instrumentenanflug, der unter Sichtbedingungen durchgefü...
i have no idea whats going on
ILS is basically "you tell autopilot how to land"
arent you meant to be flying on like tomorrow ow whatever it was
tomorrow?! no, I am totally drunk right now
i thought you were flying a commercial soon
so can i remove the java.version property?
yes
it's useless in your case
im going downstairs does any one want some food
nooo, I'm becoming a flight instructor currently
so build is now sucessfull: https://paste.md-5.net/gazuhugocu.cs
i'll try that in the mc sevrer
if I ever said that, I was drunk and I lied
but I dont recall having said that
one second ill see if i can find it
oki
in the target folder are only the temporary files right?
Alex
thank you so so much :D Now everything is working
Why isn't craftbukkit importong nms properly?
hi, i supcie my plugin infected, how to check? uncompile and search if the code have à links?
If you think a plugin is inefected
Get a new server
Also it's possible the plugin is deobfuscated so you won't be able to read it anyways
it works, but a developer of mine put it on and I suspect it
great! np
wdym
tell me you arent depending on craftbukkit and bukkit and using the spigot-api
it should find most malicious stuff
and one question: should i use jar:jar or clean package
package or clean package
is there even a difference?
clean package runs a full fresh build iirc, package just builds it
alex will correct me in a moment probably
i meant the difference between jar:jar or clean package
probably, no idea what it is
okay then i just use the clean package thing
I forked craftbukkit as well as bukkit from spigot stash and cloned in in intellij
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
look at the last 2
is it bad if i restart my plugins using /reload?
yes
/reload break plugin
use /(pluginname) relaod
not all the time
that wont work for plugin development
yes but is not good idea
that normally just reloads a config if they have it setup
if your making a plugin its normally fine
but a restart is better
I need to apply patches even if I didn't make any changes?
okay perfect
no idea, never done it before
just be ware that some errors might appear because of it and if there something you cant fix just restart and somtimes it would work lol
okay
is for some plugins
some plugins have ondisable incorrectly setup so those would break on restart
you can just use https://flags.sh if you need to auto restart on a dev server
and just disable akairs flags
so, it a bad idea to see source code to find dangerous links?
do you have git installed
how much ram is needed to create a survival economy server?
how much players you expecting
depepnds, how many plugins are you gonna have, how many players, how big is the map
Maybe more than 15 players
open git bash where the thing is and type bash runPatches.sh
Oh okay, sorry for my mistake
@tender shard if ur still here how do they do the .sh on gitbash
that's the $1 but idk anything abt bash
OHH
im dumb
i was running makePatches
not applyPatches
yesss
got it working
wdym?
?paste the whole .sh file
ah oki
ugh
didnt even know this wasnt possible
works fine with a static class but then i have to pass stuff around
@tender shard xD Now I have the same issue with a UUID. I can't deserialize it but I also can't register it too.
Should I just save it as a String or is there a better solution?
alex is asleep im pretty sure, whats your issue?
Not I get the error that the UUID I save in the yml is not deserializable as with my costum Object
I just added a uuid feld with the UUID type
but that has nothing to do with my Object I think. It is the UUID in general
check config, does it have dashes
uuid: !!java.util.UUID '5e444988-f43c-491b-af6c-92eeb302452f'
is saves it like this
ok
then on the deserialize use UUID.fromSTring iirc
yea, I already thought of this but maybe there was a better solution
but thanks anyway
yeah
hi! trying to make a disenchant plugin for players as a perk of sorts. if a player does /disenchant <enchant> while holding an item, the enchant is removed and a book is given.
this works fine for vanilla enchantments, but doesnt work the same for custom ones, even though both of them have the same key.
it does a check to see whether the custom enchantment even exists too but it wont remove it :/
[11:03:34 INFO]: [Disenchanter] minecraft:abrasion
[11:03:38 INFO]: goosBanny issued server command: /enchant sharpness
[11:03:40 INFO]: goosBanny issued server command: /disench sharpness
[11:03:40 INFO]: [Disenchanter] minecraft:sharpness
same key, yet abrasion wont disenchant.
Enchantment enchant = Enchantment.getByKey(NamespacedKey.minecraft(enchStr));
... ... ...
itemInHand.removeEnchantment(enchant);
it does, however, show that it removed abrasion in chat.
any idea?
what's even weirder is the fact that when holding an empty book in offhand, itll give the abrasion enchantment to said book just fine, but wont give the level.
but wont remove it from the sword
Have you tried using the api of your custom enchants plugin
trying to make it so itll work with any plugin rn
Not all custom enchant plugins work the same way
If it works with vanilla then it's fine
🤔 its registering in the minecraft namespace
Spigot was never designed to handle custom enchants like that
So who knows if it works correctly or not
all plugins posted in spigot ares verified? or can contain malwars?
Some can contain malware
So stay away from new plugins from new accounts
Optic does check them, but it can take a bit before they're taken down
Quick question... is there a ItemChangeCooldownEvent ?
for example for Enderpearls and Shields it would get called
How do I set an item nbt to a string? I can use item.getItemMeta().getAsString() to output the nbt of item as a string, but if I had a string such as "{CustomModelData:1,MagicSword:1b,InvisibleTool:1b,CustomEnchanted:True}", how would I set an item's nbt to that?
Time for some NMS
thinking about adding an event for this to apply or remove custom cooldowns on use
my toString goes brr
What do I need to do?
CraftItemStack should have a method for that if I remember correctly
Also why not use pdc
?pdc
Is there a way to convert a string to an item meta and just use setItemMeta() like I use getItemMeta()?
Not in the API
If I have an item from player.getInventory().getItemInMainHand(), and I have nbt stored as a string such as "{CustomModelData:1,MagicItem:1b}", is there a simple way to just set the nbt of the item to the nbt?
What is PDC?
?pdc
The example contains a variable called pluginInstance, which isn't set to anything by default, what should I set that to?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
this would double the array size and move the original elements back into it right?
Caused by: java.lang.NoSuchMethodError: 'org.bukkit.inventory.meta.ItemMeta$Spigot org.bukkit.inventory.meta.ItemMeta.spigot()'
my plugin is 1.8.8 code based ? can i do something to fix it ?
i dont use any nms code
or packets
You can update
not an option
Then don't use that method
is there another method?
I dont understand what this means, what do I set the pluginInstance variable to?
The instance of your plugin
the plugin being your main class that extends JavaPlugin
How do I make an instance of my plugin and put it in a variable?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
You already have an instance of your plugin
public class MyPlugin extends JavaPlugin {
void onEnable() {
// this refers to the current instance of MyPlugin
Something smth = new Something(this);
}
}
class Something {
MyPlugin plugin;
Something(MyPlugin plugin) { this.plugin = plugin; }
}```

exactly the same thing as in the docs
Yeah
but people won't read the docs if you keep replying here
and you skipped all the important text
java moment: cannot cast CharTree<?>.Node to CharTree<T>.Node \💀
so i have to fuck with Array.newInstance
Sounds like a problem with your code rather than Java
just because CharTree is generic and Node is not static ;-;
Yeah so ofc it's causing problems
ig Node must be created within the context of CharTree<T> and the actual type is CharTree<T>.Node then
Yeah
Hi i have a problem i just happend , i dont know why ..
so when i click on mvn clean package nothing show in the termanal [console ] or intellij idea , no errors and it compete , but the plugin size is really small
200kb
idk what happend
the plugin orginal size is 1,3mb
just click on package
its working now .. before 5 minutes it was'nt building the correct plugin
and without any libs ..
i didnt pay alot of attention to formattingz arent there any common formatting rules for java? besides naming conventions
class names in UpperCamelCase var names in lowerCamelCase, package names lower case
besides naming conventions
didnt read that far
we have a command for that
"then" is present in java
so you can have oneliners
if (smthIsTrue) doSomething();
else doAnotherThing();
dont nest ifs like what nukersaid and instead of doing something like
if (playerIsSus() {
do something sus;
} else {
return;
``` do
```java
if (!playerIsSus()) return;
do something sus;
i read it 🥰
bruh that's literally made for another purpose
oh nice
there is no return in my code
im just giving another tip
and also this can be applied to else if
@remote swallow
this is generally how it's supposed to be done in programming, the oneliner is nice tho
"dont nest ifs like what nukersaid"
nah im just giving an extra tip lol
my space bar doesnt work sometimes
happens
so works look weird
Is there a method for loading a chunk even if players are not there?
Had this cracking idea of a plugin for further mitigating cheating players whom, even after rollback have managed to get away with it via various work around by grabbing coordinates of various item exchanges, loading the chunk, checking the containers and seeing if the items of equivalent are there, give an option to delete them, then de load the chunk
plugin ticket iirc
*get away with cheating core protect
?
Ahh fantastic cheers
help? :/ my server still timeout
?whereami
Also when you're in the Paper discord don't screenshot the logs and show the entire thing
paper moment
ah yes streaming a collected stream
why does sending zombie entity spawn packet not work in the nether o. o
no way the client refuses it
does it?
probably not
Probably something wrong with your code
most likely
I doubt even more that zombies are broken in the nether
yeah like send a packet saying you're a spectator
i checked and made some debug strings
packets are for sure sent
but why do they not work?
no clue
"and" i was giving another tip for them
you can't change entity id in a packet mr smarty
plus this code works fine in the OW
nope
entityID not uuid
to make a player look like an entity
pls don't change the subject
THIS PACKET WORKS OML
it works as long as you're not in the nether
or the end
only OverWorld
stop
not helpful
Question, what does https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityChangeBlockEvent.html affect?
declaration: package: org.bukkit.event.entity, class: EntityChangeBlockEvent
Will it include stuff like explosions? or is it just stuff like zombies breaking doors?
its on the javadocs
that was like 100ms response
yes but exactly what triggers it?
is it just zombies breaking doors and enderman moving blocks?
or is there anything else im missing?
was about to say that
Well it looks like EntityBreakDoorEvent extends EntityChangeBlockEvent
so wouldnt EntityChangeBlockEvent also include break door event?
or is that not how that works
and a more specific event is not available ah thats not how that works
kinda dumb imo
hmm alright
thanks
?paste
https://paste.md-5.net/apuwodifos.cs - For some reason it only works once, on right click it opens the inventory but once i close out and right click the item again it doesn't do anything? I've debugged and the event is still firing and not getting stuck anywhere
ahhh yeahh
well return breaks the whole function xD
intellij will probably scream at you for using it just ignore it
intellij never screamed at my continues
why would it
maybe you are just using them wrong
almost every time ive used it intellij just wants me to die
sounds like a personal issue then
intellij just doesnt liek me
mm I love code samples that don't follow any structure
are you sending a death message
after running that
dont
use the death event
or canel the death event
or better set the death event message to null
i would guess the death event is called when you set the health to 0 then it triggers again for some reason
is the death message handled just after you set the health to 0 or do you handle the death message on the death event
i would guess the only way that could happen from that code you provided is that theres 2 instances of the plugin running
i mean the plugin has loaded twice
yeah
im guessing its triggering when you set it to 0, and triggering the next tick
you could just set there health to 0.5
and within the next 10 ticks they would die to the void
also on your damage check, check if their health is already 0.5 or lower
otherwise you'll get into an un-die able state probably
lol
Hello! I am developing a plugin and I need to pass the skin of a SkullMeta item into another. How can I achieve this?
newSkullMeta.setOwnerProfile(oldSkullMeta.getOwnerProfile());
This example is not working at all.
any errors
No errors. Yes, I set the meta back.
old skull
well is the owner of the old skull a player or a texture
Its a command given skull
I think its a texture
if its a players head you probably need to use getOwningPlayer and setOwningPlayer
idk how else the old skull owner wouldnt be set from that
I did that and its not working at all so it seems its a texture
How do I pass a texture?
I am basically making an antiexploit plugin, and to prevent illegal items I recreate the entire item and pass the values
are you on 1.18.2 or soemthing or above?
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.nameUUIDFromBytes(texture.getBytes()));
PlayerTextures textures = profile.getTextures();
try {
textures.setSkin(new URL(TEXTURE_URL + texture));
} catch (MalformedURLException e) {
e.printStackTrace();
}
profile.setTextures(textures);
((SkullMeta) this.meta).setOwnerProfile(profile);
would be something like that
texture url is http://textures.minecraft.net/texture/
if it isnt giving an error ive got no idea
Its not giving any errors
you might
Is there an alternative way to pass the texture?
not that i know of
hey guys i'm back :P I want to create a npc using npcLib but for some reason the npc is not spawning
Main.java: https://paste.md-5.net/bobodipulu.java
npc/NPCManager.java: https://paste.md-5.net/modetucuqi.java
unrelated but you can do TabComplete and the command in the same class
and you dont need to setTabCompleter
setExecutor does it
since always
ratio
wdym
you dont need the getCommand("nickname").setTabCompleter(new NicknameTabComplete()); if you do tab complete in the same class as the command
Hi there! May I ask a question whilst there is already a question being answered, or must I wait?
ask away
alright
that library looks fairly awful, citizens api might be better
So, as of now, I'm trying to play around a bit with multi-protocol support without viaversion etc. and I was looking at wiki.vg for the loginstart packet:
https://share.sweetaurora.tech/leni3/navELito21.png/raw
However, weirdly enough, the has player uuid portion is never sent to me, making me unable to verify i.e. the public key and more, does anyone know what's going on?
as I can't imagine wiki.vg being wrong about this one
is the has player uuid true?
oh okay :C I spent two hours trying to understand how this thing works and now... but okay thanks anyway
It is not sent
the boolean
that entire field is missing
I read the following
String (name, is there)
Has Sig Data (true, is there)
all the other fields
and then it just ends at Signature
is your server in offlinemode?
they dont exist pre 1.19.1 iirc
because messages and that werent signed before those versions
Hmm, then, why is the key etc. being sent instead of i.e. nonce
and wiki.vg does mention the packet being this way, and as far as I can read matches until the last 2 fields
like this?
package com.koner.konerutils.nickname;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class NicknameCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
String nickname = args[0] == null || !args[0].equals("delete") ? args[0] : player.getName();
player.setDisplayName(nickname);
player.setCustomName(nickname);
player.setPlayerListName(nickname);
return true;
}
public class NicknameTabComplete implements TabCompleter {
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
List<String> arguments = new ArrayList<>();
arguments.add("s");
arguments.add("name");
return arguments;
}
}
}
no need for the other class
just put the method directly in the NicknameCommand
oh i forgot that xD
it might be the server creating those fields
or viaversion
Like this?
package com.koner.konerutils.nickname;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class NicknameCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
String nickname = args[0] == null || !args[0].equals("delete") ? args[0] : player.getName();
player.setDisplayName(nickname);
player.setCustomName(nickname);
player.setPlayerListName(nickname);
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
List<String> arguments = new ArrayList<>();
arguments.add("s");
arguments.add("name");
return arguments;
}
}
yeah
perfect :D
if you want tab complete to respond to what they type use StringUtil.copyPartialMatches(args[num (starts at 0)], list, new ArrayList<>())
Hmm, you're right
I'll look into it
== 1 not 0 lol
args[] starts at 0, args.legnth starts at 1
if the legnth is 0 the theres no args
you probably need sleep
ago or for 12 hours
the only confusing part is that counting starts at 0 and not 1
sounds like its not a brain day
the rest should just make sense
is now the right time
havent touched packets and i really dont want to
couldnt tell you what there called but im guessing you would need to allow or send movement packets that allow people to go into blocks
and set them as not colidable and set them as invis
@remote swallow thanks, got past it now
turns out it does not send UUID on 1.19
and sends it at https://share.sweetaurora.tech/leni3/kUronILi17.png/raw
set the player you want to hide as colidable false
i would guess thats how that works
if not, good luck on scoreboard teams
looks like your gonna need scoreboard teams so they dont colide with online players
but online players can colide with online players
by online i mean alive
brain didnt brain
Players collide on the client, so if they can't see the player they won't collide
Then something changed
because I recall hiding players and collision being gone automatically
Ohh right
The block disappears, right?
after attempted placing
yeah, it doesn't collide
that just the server going 'you can't place that here'
because of the player, no?
Paper 💀💀
this is very sad
Noo, it's perfect paper takes out those problemátic ppl
Because You join paper and they put You in your place. So after some days they came back to spigot remastered tho
Oh it's a plugin
who
oh
yeah
i scared the guy that made it off, i think he was coming here asking for help
Oh lmao i thought You we're about those problemátic ppl who complain here, sayimg i Will use paper instead of this shit. But some days after they realize their comm is really shity and cane back to spigot
lul
whats interactive chat
A plugin
I thought it's was an author
ah that
sometimes people will get called thing-there-known-for guy
Lmao i don't realize i can use this thing, it's perfect tho
Written by talpback
This error is multiple times in all of my files: Not annotated parameter overrides @NotNull parameter. How can I fix that?
package com.koner.konerutils.nickname;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class NicknameCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
String nickname = args[0] == null || !args[0].equals("delete") ? args[0] : player.getName();
player.setDisplayName(nickname);
player.setCustomName(nickname);
player.setPlayerListName(nickname);
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
List<String> arguments = new ArrayList<>();
arguments.add("set");
arguments.add("get");
arguments.add("delete");
return arguments;
}
}
Skulls have no gameprofile for some reason
I need to get the GameProfile of the clicked skull to get its textures
im pretty sure those variables in the method need to have @urban grotto
A) Annotate NotNull params as NotNull
B) Fix your IDE settings
You cant get Game profile from a skulk
How bro
okay
I want to disable those shity intellij warning about @Nulleable and @urban grotto warnings
Like this:```java
public boolean onCommand(@NotNull CommandSender sender, Command command, String label, String[] args) {
If you were to use eclipse I'd know, but if you were to use IJ you'd surely know how to do it yourself given how easy to use it is (according to you guys that is)
but it underlines that red and error: Cannot resolve symbol 'NotNull'
Import NotNull from JB annots then
okay but i think i'll just turn off these errors in intellij
It should suggests turning off the warnings in IJ anyways
@urban grotto is still there
Oh lmao
Not sure if the questions belongs here:
Is there any obligation to sell premium plugins on spigotmc?
Not as in a one time commission but more like a private collections of premium plugins with e.g a discord server?
The benefit to selling on spigotmc is that more people will view it and trust it rather than from an external page.
I understand. But would it be allowed?
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
I'm sure it's fine
Are u sure?
why would it not be?
Some months ago we did something similar and they banned our community spigot acc because we we're selling custom collection of plugin which we're managed by our custom page
Yeah pretty sure. Not like SpigotMC makes commission. It's also not in the license https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/LICENCE.txt
Well THAT is not allowed
See, that might violate the SpigotMC website ToS
But it doesn't violate the Spigot License you agree to when using the library
But selling outside of spigot? Fine, as long as you don't create a spigot acc for that
I also dm optic but he didnt even answer tho and i get really sinxe that
optic doesnt read his dms i dont think
Well i explained how it used to work, we we're listening to spigot buys to the plugin on our backend, so for downloading it You used to log on our site, why? Because our backend manage the downloads and plugin updates, etc. So once you log in on our site You can download ir from there the resource
that goes against premium rules
because the plugin wouldnt work if your backend went down
No
Because the download button download the jar normally as every premium pl does it and the ñlugkn itself doesnt depend on the backend
There no rule is breaken
md would respond probably
It isn't that great unless you ask it proper questions, and it's not great for super specific stuff sometimes
final code ig https://paste.md-5.net/ujituqifif.java
i once visited md5's personal site and whenever i type "pa" in my browser it suggests me that site ;-;
and ofc it has bugs
Sorry, your toString() really bothers me
StringBuilder sb = new StringBuilder();
if (this instanceof ValueHoldingNode) {
sb.append("ValueHolding");
}
sb.append("Node{'").append(value).append("', children=");```
Massive no-no to check for subtypes in the parent. That's why we have overrides
I would override toString() in the child class and append ValueHolding in front of super.toString()
might just use getClass().getName() too
or simple name whatever
Was a minor annoyance lol. Doesn't affect performance, only my soul
How did You get that??
I want to try that intelligence
how did i get what
The mesaage You sent
This
is that supposed to be english?
How do you get that mesaage you have sent? I just used to AI for searching for general things and getting info
Written by talpback
ah yes Expression '4(5-1)' returned -4,0000000000, expected 16,0000000000
my 5 disappeared
That is the query you sent to the AI
no
So
Are u trolling
🤔😂
Also why many ppl prefer using shity plain NIIO socket instead of Netty? It's pretty important this question
whats wrong with it
Okay i realize You never use them for doing the same thing
No?
Weird
My file handler doesnt mkdir?
ok copilot fixed it lol
really need to make things simpler cuz this looks awful
reading a simple number is even worse
Oh lmao i realize why doesnt happen that issue My file handler use the next methods:
void createParent() throws Exception {
this.file.getParent().mkdir();
if (this.plugin.getResource(this.name) != null) this.plugin.saveResource(this.name, false);
this.createFile();
}
void createFile() throws Exception {
this.file.createNewFile();
}
why creating a new file after you just saved it
That because in case You don't provide the scheme file, it Will create an empty file
If You don't provide the file in resource folder, would throw an Exception so instead of that i just create the file empty
What was the name of the module loader You recommend me?
ServiceLoader was named?
smth like that
yes ServiceLoader
💀
anyone here familiar with intellij crashing when I just want to select some words? it like freezes and then says low memory
Best way/API for player nametags? No nametagedit because it's old and has a lot of bugs.
thats not even 1/10th of it
how can i read the config of another plugin?
20k bytes character property tables 💀
Just get the file
You can probably get instance of its JavaPlugin with getPlugin(class) and get their config
rust user i see
Or just get file as suggested
PluginManager#getPlugin(String)
which returns a Plugin and #getConfig exists ther
assuming you know its name
my current method is to just get the file yes, but it would be cleaned to just read its config
Then use what fourteenbrush suggested, it's better solution then mine, didn't know that method exist
hmm so i need to import it as an dependency then? (i am still very new to java/plugins)
I like simple yaml, it's same api as bukkit's
eclipse doesn't seem to be working for me, i added a spigot 1.8.8 library and after i import the package it says the JavaPlugin class doesn't exist, even though it does
I have My own FileHandler which extends YamlConfiguration (bukkit yaml api) and works amazing. Never have any type of issue
?1.8
Too old! (Click the link to get the exact time)
Also for coding i would never suggest Eclipse, i would even use Vscode over that thing
eclipse user, go to the shame corner
wow ok
stop
what do u use then
intellij
Intellij
this isn't even close to java
Intellij is the most widely IDE use
people thinking 20L is any different than 20
also you don't change the entity id through entity class
I always have thar question
I assume its kind of pseudo code
compiler fixed it
he's not helping me solve my issue
he's just throwing random links
i dont get this though
and some weird weird code
a lot of people use 1.8.8 and play on 1.8.8 servers
well its just not very widely supported by developers afaik
5.6%
most people here refuse to give any support for it
@sterile token can you take a guess why does this not work in Nether?
https://paste.md-5.net/jacesekise.cpp
you have more knowledge ig
hmm thank you
Sorry tho
Save it as string, then retrieve it with UUID.fromString
Alex
can ya take a guess
maybe you're more experienced in packets 
actually i find something interesting
if the disguised player walks on undisguised players in the Nether it works fine
but if its the other way around it doesn't
ugh i would ping Choco but i dont like pinging without permissions 😦
morning alex
Does anyone know how I can dye a material item in 1.8? Specifically STAINED_GLASS_PANE
ItemStack fill = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 9);
is what I have so far
hewwo
isnt this correct?
did you dream about maven again
ah
he was touching sql
i don't like sql
Doesn't seem to give me a color though
let alone a stained glass pane.
show your full code
would BookMeta serializer be in craftbukkit or bukkit
CraftMetaBook -> CB
ah
public static void openMainBankMenu(Player player){
Inventory mainbankergui = Bukkit.createInventory(player, 9, ChatColor.translateAlternateColorCodes('&', MCBanker.getInstance().getConfig().getString("BankerName")));
// Fill Item
ItemStack fill = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 9);
ItemMeta fill_meta = fill.getItemMeta();
fill_meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', MCBanker.getInstance().getConfig().getString("FillerName")));
fill.setItemMeta(fill_meta);
// Deposit Item
ItemStack Deposit = new ItemStack(Material.matchMaterial(MCBanker.getInstance().getConfig().getString("DepositMaterial")), 1);
ItemMeta deposit_meta = Deposit.getItemMeta();
deposit_meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', MCBanker.getInstance().getConfig().getString("DepositName")));
ArrayList<String> deposit_lore = new ArrayList<>();
deposit_lore.add(ChatColor.translateAlternateColorCodes('&', MCBanker.getInstance().getConfig().getString("DepositLore")));
deposit_meta.setLore(PlaceholderAPI.setPlaceholders(player, deposit_lore));
Deposit.setItemMeta(deposit_meta);
// Withdraw Item
ItemStack Withdraw = new ItemStack(Material.matchMaterial(MCBanker.getInstance().getConfig().getString("WithdrawMaterial")), 1);
ItemMeta withdraw_meta = Withdraw.getItemMeta();
withdraw_meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', MCBanker.getInstance().getConfig().getString("WithdrawName")));
ArrayList<String> withdraw_lore = new ArrayList<>();
withdraw_lore.add(ChatColor.translateAlternateColorCodes('&', MCBanker.getInstance().getConfig().getString("WithdrawLore")));
withdraw_meta.setLore(PlaceholderAPI.setPlaceholders(player, withdraw_lore));
Withdraw.setItemMeta(withdraw_meta);
// CreateGUI
mainbankergui.setItem(3, Deposit);
mainbankergui.setItem(5, Withdraw);
player.openInventory(mainbankergui);
}
mmm formatting
what do you expect to happen?
you create a "fill" ItemStack and then never use it for anything
How do you call that tree-like structure that recursively divides the space into four child nodes? Kinda forgot the name 😅
naming conventions out the window
quadtree?
Yep, thanks
<insert itembuilder here>
I always think it's quaternion, but it isn't. My brain is a fool sometimes
octree is cooler
PhotovoltaicJump: paid java lessons
FAEE JRVA LESSONS
FRAE JAVA LESSONS
.forEach(p -> {
if(p.getName().equals("listener")) {
}
});```
how could i get all listeners in this package using reflection?
SELF LEARNING EXERCISE
i suggest you use https://github.com/ronmamo/reflections
i can use class loader but i don't know how
wdym you can use class loader?
I did something similar using ClassGraph in the past
But uh, that is an enormous dependency
i personally used Reflections, and it is very easy2use
if you wanna avoid that, or prefer another option, look here
https://stackoverflow.com/questions/520328/can-you-find-all-classes-in-a-package-using-reflection
a few of the answers doesn't use any libraries
there are also options with Guava which is included with spigot
But hey, it might be more economical to use cafed00d, asm (though be aware that that one doesn't always work if you are doing stupid stuff with obfuscation), or similar libraries
well it uses ClassLoader.getSystemClassLoader, but spigot implements it's own for plugins, so there's a chance it might not work
(i.e. it does not work)
if you replace the ClassLoader.getSystemLoader() with plugin.getClass().getClassLoader() it should work ig
I don't believe that that works at all
why tho?
How do I make it so when they click while holding an item it opens a gui?
listen to player interact event
okay it works. But it is the most cursed piece of code I've seen to date
package Listeners;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import javax.swing.*;
public class opengui implements Listener {
@EventHandler
public void onOpenGui(PlayerInteractEvent e){
Item itm = e.getItem();
}
}
im tryna make a variable
Folders should be openable through input streams... but whatever
Remove the javax import, you 100% don't want that
Else, you might have issues on macos
ight
but my variable
@EventHandler
public void onOpenGui(PlayerInteractEvent e){
Item itm = e.getItem();
ohh
the item one
