#development
1 messages · Page 140 of 1
One way you could do it is instead of referencing a sword field, call a getSword() method that dynamically builds it from the config
That way it would always check the config
how should i go about pulling the getSword() on the right click event?
Just make it a method inside that class
ah okay
working now thank youuuu
np 👍
What issue are you having?
uhm i think actually i figured it out?
@winged pebble so like
how do i get the changes to automatically apply inside the debug environment
it states
Building your project will inject the changes to the server
but building my project did no such thing
What are you following?
Spigot
Does paper not support swapping?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I figured it would be the same but i suppose not
List<Integer> distances = Arrays.asList();
distances.add((int) b.getLocation().distanceSquared(player.getLocation()));
Why isnt this being added into the array?
Because it's a list
So how would I add it in? 😮
List<Integer> distances = new ArrayList<>();
distances.add();
Arrays.asList() is immutable, no?
Or is that just the other ones that return immutable lists
no, it returns a list wrapper around the the array
means you can do everything with it what you can do with the array too
and changes to the array are visible in the list and vice versa
It does say it returns a fixed size list
Which leads me to believe you can't add or remove from it
yes, just like arrays
final ProcessBuilder processBuilder = new ProcessBuilder(command.split("\\s"))
.directory(sourceFolder);
Procress process = processBuilder.start();
Does anyone know if it's possble to bind some sort of Shutdownhook that gets called once this specific procress is stopped/destoryed?
d; Process#onExit
public CompletableFuture<Process> onExit()```
Returns a CompletableFuture<Process> for the termination of the Process. The CompletableFuture provides the ability to trigger dependent functions or actions that may be run synchronously or asynchronously upon process termination. When the process has terminated the CompletableFuture is completed regardless of the exit status of the process.
Calling onExit().get() waits for the process to terminate and returns the Process. The future can be used to check if the process is done or to wait for it to terminate. Cancelling the CompletableFuture does not affect the Process.
Processes returned from...
This description has been shortened as it was too long.
9
a new CompletableFuture<Process> for the Process
@sterile hinge Thanks, appreciate it
Hey
I have a mate who wants to host a minecraft server with crossplay
He uses realms but realms is shitty
And he claims there's no way to host your own server and allow crossplay
But I really don't believe that
Like he wants to play on PC with his mates on ps and xbox
Java Server + Geyser Bridge
is it possible to allow players to create a alias to a command?
doubtful
I know I can collect the list of alias save to a config and at bootup load that config, just not should how to add to the command as a alias
anyone know the issue to this?
[08:31:30 WARN]: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '),PLAYER VARCHAR(100),UUID VARCHAR(100))' at line 1
?
validate your sql syntax through online tools like eversql
you can add command aliases in the commands.yml of the server itself if that's what you are looking for
aliases:
original_command:
- new_alias_you_want $1-```
all it is just
you mean sql syntax is correct?
ok wait
im just as confused
no it's invalid syntax
just edit like this
if you want to set size to DOUBLE, you have to do that like DOUBLE(5,0)
like DECIMAL
ah wrong this is the desc from mariadb document
M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits allowed by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places.
(M,D)
I've got this issue:
UUID playerUUID = (UUID) config.get("players." + player.getUniqueId());```
The second part is the data type Object and cannot be cast to UUID, how would one convert it to a UUID format?
I think your original size in sql was 100 so, I think you don't have to specify size
ty
im done my Mysql api
you can set
ints, doubles, strings, and uuids
🙂
just a test class
This doesnt work unfortunately
let me see your config
java.lang.ClassCastException: class org.bukkit.configuration.MemorySection cannot be cast to class java.lang.String (org.bukkit.configuration.MemorySection is in unnamed module of loader java.net.URLClassLoader @5c29bfd; java.lang.String is in module java.base of loader 'bootstrap')```
public static boolean doesPlayerExisit(Player player){ //Checks if player is in data.yml
String playerStringUUID = (String) config.get("players." + player.getUniqueId());
UUID playerUUID = UUID.fromString(playerStringUUID);
if (playerUUID == null) {
return false;
}else {
return true;
}
}```
players:
6b7b95b0-85b5-30cf-b997-271790f60040:
currentXP: 0
currentLevel: 0
give me a sec
It cannot be cast
cant you just
But its the data type object so I can cast it to anything
Question is how to have it in UUID format
you do understand that config.get("players." + player.getUniqueId()); will return yml currentXP: 0 currentLevel: 0
not the uuid right?
if you want to check if there is data for that uuid inside the gui, use config.contains(player.getUniqueId().toString())
d;spigot YamlConfiguration#contains
boolean contains(@NotNull String path)
throws IllegalArgumentException```
Checks if this ConfigurationSection contains the given path.
If the value for the requested path does not exist but a default value has been specified, this will return true.
path - Path to check for existence.
IllegalArgumentException - Thrown when path is null.
True if this section contains the requested path, either via default or being set.
Thanks
okay i have a issue with my rounds system
i have 4 rounds
but when i finish round 2
java.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3```
but i orginized them
for (GameRound gameRound : Main.getRounds()) {
if (i == gameRound.getRound()) {
rounds.add(Main.getRounds().get(i));
Main.getRounds().get(i).setGame(this);
}
}```
you're using outer for loop for just to get index?
use index variable or ArrayList.indexOf() instead.
dwym
because
i have round 1
2 3 4
and i need them to be
1,2,3,4
i have a list of all the game rounds
in Main.getRounds()?
super(round name: "Round 3", round: 3, new MobSpawn(new Testombe(), 1), new MobSpawn(new Testeliten(), 1));
setAmountOfMobsNeeded(2);
}```
thats the game round class what it looks like
and this is the next round
System.out.println(game.getRounds().size());
GameRound newGameRound = game.getRounds().get(getRound() + 1);
newGameRound.onStart();
game.setRoundIn(newGameRound);
}```
did you check the size of Main.getRounds() and index 'i' inside of for loops
just print them to console
that error you pasted is literally index outbound error
lets go thru this
so there are 4 rounds
and it prints the size as 3
becuase 0,1,2,3
4
so when im on round 2
and try to go into round 3 it says out of bounds?
that's why you should check that thru debug... because there's no prob you're saying
let me print i
yup
hmh
[09:45:55 INFO]: [Zombies] [STDOUT] §c2
[09:45:55 INFO]: [Zombies] [STDOUT] §c3```
there are 4 rounds thoo
the math aint mathing up
try {
GameRound round = (GameRound) clazz.getDeclaredConstructor().newInstance();
getRounds().add(round);
} catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
e.printStackTrace();
}
}```
public static List<GameRound> rounds = new ArrayList<>();
im not no mathmaticisan but if 4 + 0 = 4
I can't help you til can't see the entire code. But according to the error message it is clear that your're trying to access index '3' of list which size is 3.
so how do i get the next round of the list?
don't you have currentRound in class?
I don't think you can do that without knowing which round is runnning
getRound() is just the round int
lets say im in round 1
then getRound() = 1
so to go to the neext round i do +1
ah you have current round
for (int i = 0; i < Main.getRounds().size(); i++) {
for (GameRound gameRound : Main.getRounds()) {
if (i == gameRound.getRound()) {
rounds.add(Main.getRounds().get(i));
Main.getRounds().get(i).setGame(this);
}
}
}```
so turns out
this only goes to round 3
thats the only way i found to orginize them
idk what to do to fix it
so for this
it loops 1 then goes threw all the rounds till it sees a match but when it gets to 4 it skips?
how i can make a lib?
i mean
add the repository in pom.xml and can access its methods
You need to publish it to some maven repository
There's maven central and jitpack which are both free and easy enough, or you can self host with something like reposlite
so i'm trying to spawn a villager with a certain location rn with this: ```java
Location loc = new Location(Bukkit.getWorld("world"), -1.5, 114, 12.5);
loc.setYaw(45);
loc.setPitch(45);
Villager perks = (Villager) Bukkit.getWorld("world").spawnEntity(loc, EntityType.VILLAGER);
perks.setAge(9999999);
perks.setProfession(Villager.Profession.PRIEST);
net.minecraft.server.v1_8_R1.Entity nmsEntity = ((CraftEntity) perks).getHandle();
NBTTagCompound tag = nmsEntity.getNBTTag();
if (tag == null) {
tag = new NBTTagCompound();
}
nmsEntity.c(tag);
tag.setInt("NoAI", 1);
nmsEntity.f(tag);
perksVillager = ((CraftEntity) perks).getHandle();
Why isn't this possible with C# 😦
<a class="btn btn-secondary" href="@xmlMethods.changeStyle();" role="button">Verander style</a>```
Everything would be so much easier 💔
you should have put that in #dev-general , not here
that's not really how browsers work
they only do javascript, and not in the href
No, but this channel is specifically for support rather than jokes and stuff
Clearly you've not used thymeleaf
can anyone help me with this?
Don't the buttons have a "function" attribute that does basically that?
sounds like you didn't put your redis connection details in correctly
a timeout means that it tried a few times to connect to the server and couldn't
so i'm trying to spawn a villager with a certain location rn with this: ```java
Location loc = new Location(Bukkit.getWorld("world"), -1.5, 114, 12.5);
loc.setYaw(45);
loc.setPitch(45);
Villager perks = (Villager) Bukkit.getWorld("world").spawnEntity(loc, EntityType.VILLAGER);
perks.setAge(9999999);
perks.setProfession(Villager.Profession.PRIEST);
net.minecraft.server.v1_8_R1.Entity nmsEntity = ((CraftEntity) perks).getHandle();
NBTTagCompound tag = nmsEntity.getNBTTag();
if (tag == null) {
tag = new NBTTagCompound();
}
nmsEntity.c(tag);
tag.setInt("NoAI", 1);
nmsEntity.f(tag);
perksVillager = ((CraftEntity) perks).getHandle();
I don’t know
I made a joke of it, but i need some help with it
Is it possible to trigger a C# function in JS then?
Unless I'm missing something, browsers don't know to interpret c#
does anyone know how to organize a list of rounds?
right now it only goes from 1,2,3 then doesnt add 4
List<Integer> ints = new ArrayList<>();
for(GameRound gameRound : Main.getRounds()){
ints.add(gameRound.getRound());
}
Collections.sort(ints);
for(int i : ints) {
for(GameRound gameRound : Main.getRounds()) {
if(i == gameRound.getRound()) {
rounds.add(gameRound);
gameRound.setGame(this);
System.out.println(ChatColor.GREEN + gameRound.getMessage());
}
}
}```
d;Collections#sort
public static void sort(List list, Comparator c)
throws UnsupportedOperationException, ClassCastException, IllegalArgumentException```
Sorts the specified list according to the order induced by the specified comparator. All elements in the list must be mutually comparable using the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the list).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The specified list must be modifiable, but need not be resizable.
list - the list to be sorted.
c - the comparator to determine the order of the list. A null value indicates that the elements' natural ordering should be used.
UnsupportedOperationException - if the specified list's list-iterator does not support the set operation.
ClassCastException - if the list contains elements that are not mutually comparable using the specified comparator.
IllegalArgumentException - (optional) if the comparator is found to violate the Comparator contract
by sorting the list by the round number
i thouight that shit only worked for a list on numbers
thats why u use the second parameter
normally it only does (more specifically, any Comparable type)
did 1.19 break stuff related to actionbar and chat?
Yes... It removed ChatTextCompound
If you read above I actually had so many issues with it lol
it now sends on actionbar xdd
Do you use packets for the action bar or do you use the API?
Anything over 1.9 I use
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(text));
i mean, i'm, using a plugin for staffchat that sends message in chat
but i just connected with 1.19 and it sends it on actionbar insteadd xd
and yeah, i use that one for anything over 1.8.8 in my plugins too xd
Thats odd... If its open source check the code.
can someone help me out with this? this guy released the source code for his project https://github.com/IlluzionzDev/CustomFishing/releases/tag/4.1.3 but there is a dependency missing from the scope and he sent me this link & just said compile it with no further information.. maybe you guys understand better than me because its my first time https://github.com/IlluzionzDev/Mist fyi the author isn't being very helpful
I'm using intelliJ
Hello there
so i want to make bungeecord (waterfall) plugin that will get strings from the list with "target-usernames" and it'll compare to player that left the server (bungee's PlayerDisconnectEvent)
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDisconnect(PlayerDisconnectEvent ev) {
ProxiedPlayer p = ev.getPlayer();
for (String u : plugin.getConfig().getStringList("usernames")) {
if (p.getName() == u)
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), plugin.getConfig().getString("command").replaceAll("%username%", p.getName()));
}
}
this is what i got, although this do execute command that targets player that disconnected, but it doesn't target player i enter in usernames list, it does this to ANY player that leaves proxy server
my config.yml
command: "ban %username%"
usernames:
- "TheJoshua"
Use .equals to compare Strings, not ==
so if (p.getName().equals(u))?
yes
will test now
though you should also probably be working with UUIDs, not usernames, as usernames can change
weird enough, it still does ban any player that leaves the proxy server...
even though p.getName() is not at all the same as string from list (of usernames)
and i checked that by broadcasting current string while in for loop
i will try to later
Worked, thanks @dusty frost !

is there a way to execute bungeecord command while no player is online?
Hey. Odd issue here.
Is there a way to completely cancel all clicks/packets from being sent to the server?
I don't want specific players to be able to click and so they won't be flagged by anti-cheat for excessive clicks per second
Most anticheats have permission to bypass...
im using NoteBlockAPI and im getting the error ""package com.xxmicloxx.NoteBlockAPI.model does not exist""
can anyone help @here
also yes the file is there in my external libraries
does anyone know how to spawn a villager facing a certain direction
Anyone knows how to add multiple version support in our own Minecraft plugin? I'm still a beginner and that's why I'm asking about it.
make it 1.19 change the api version to 1.17(in plugin.yml) and it should work on 1.18 - 1.19
If you need to use nms across multiple versions, people often create modules for each version
how tf do you add lore to an item? It requires a component to do so, idk how to construct one
Component#text
ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);
ItemMeta im = item.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("hi");
im.setLore(lore);```
setLore is deprecated & that is the only thing I can find
I understand it needs a text component but idk how to make 1 bc the one I'm using kicks back a syntax error
You add the component which you get by passing your string to Component.text
can you show me some example code? nothing I'm trying is working
Well what are you trying?
Component.text(“Hi”)
Kinda like that.
ok I get that
but look at my code
ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);
ItemMeta im = item.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("hi");
im.lore() = Component.text("hi");```
You’re not setting the item meta
Read the error, it'll make things clearer
so change it to a list of Components
NPE?
NullPointerException
This is what you need basically```java
List<Component> lore = new ArrayList<>();
lore.add(Componet.text("hi"));
meta.lore(lore);
that or if you add to the lore aka meta.lore().add(component) it'll make a new index
yeah you just need to make sure it hasLore() first
ooh right gotcha
also just using meta.lore().add(component) won't work. it won't update the lore. you have to do meta.lore(meta.lore().add(component)) or something like that
ok so my goal is to get the caught entity that is on the end of my fishing hook, & to change it to a custom item.. I'm not sure that it is working
@EventHandler
public void onFish(PlayerFishEvent event){
if(event.getState().name().contains("CAUGHT")) {
String category = pickFish();
Item entity = (Item) event.getCaught();
if (entity != null)
entity.setItemStack(createItem(category));
}
}```
public ItemStack createItem(String node){
ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);
ItemMeta im = item.getItemMeta();
im.displayName(Component.text(node+".displayName"));
List<Component> lore = new ArrayList<>();
for(String line : config.getConfigurationSection("lore").getKeys(false)){
lore.add(Component.text(line));
}
im.lore(lore);
if(config.get(node+".enchantment") != null){
im.addEnchant((Enchantment) config.get(node+".enchantment"), config.getInt(node+".level"), true);
}
item.setItemMeta(im);
return item;
}```
ok so getCaught is like if I were to hook a player, it would return the player & not the actual fish that I get
I think?
not sure anymore
You want them to fish, and instead of getting a fish for example, you want them to get something else?
yeah I want them to get fish but my own custom fish
CAUGHT_ENTITY is when they hook a player or mob
CAUGHT_FISH is from fishing normally
So just check CAUGHT_FISH instead of both
wdym?
You don't want to check if the state is CAUGHT_ENTITY
the state of getting a fish will return like CAUGHT_FISH
But currently, you're checking both CAUGHT_ENTITY and CAUGHT_FISH
I'm trying to actually get the (ENTITY) of the fish that gets pulled in when I retract the hook
Right, but your logic is off right now
yeah I got that part
But the rest should be fine
so the event.getCaught() is returning null
d; spigot PlayerFishEvent
public class PlayerFishEvent
extends PlayerEvent
implements Cancellable```
PlayerFishEvent has 1 all implementations, 10 methods, 1 implementations, and 1 extensions.
Thrown when a player is fishing
Entity caught by the player, Entity if fishing, and null if bobber has gotten stuck in the ground or nothing has been caught
I assumed CAUGHT_FISH meant they had an item on the hook
Should
omg I'm dumb..
the issue wasn't even in my fish catching method.. it was in the pickFish method
public String pickFish(){
double rnd = Math.random() * maxWeight;
for(String fish : config.getConfigurationSection("item").getKeys(false)){ //<--------------- it needs to be items & not item.. sigh
double choice_weight = config.getConfigurationSection("item."+fish).getDouble("chance");
if(rnd < choice_weight){
return "item."+fish;
}
rnd-= choice_weight;
}
return ""; //will never reach here
}```
so the issue is
ItemStack item = new ItemStack((Material) config.get(node+".material"), 1);```
can't convert string to material
how do I get a material from a config?
nvm material.getmaterial
I got everything working btw
I am trying to auto-compress the old Log file when I start my application, the problem is it doesn't compress. This is my current attempt: https://paste.teamhelios.dev/iHJgOFHE6y
preferably it should work without using Processes
you can also use Material.valueOf()
also since when is ItemMeta#setLore() deprecated?
or is it just paper that deprecated it
It's just paper
getMaterial/matchMaterial is generally better
valueOf must be an exact match, the others will check for things like legacy plugin compatibility, are case insensitive, will turn some characters like - or into an underscore etc
though realistically, the registry should be used
HikariConfig#addDataSourceProperty(key,value)
requires value as string? or it can be other types?
I mean, for example, with "useSSL", it needs to be "true" as string or true as boolean (from config.yml)
i said that cus for some odd reason getMaterial worked, like it returned the material, but would shoot a npe or something that that when using the result, which was odd.
valueOf worked fine
yeah because exceptions are fucking garbage
actually looking back, you are unable to add to a Set<Material> if that string was parsed with Material#getMaterial() but worked just fine as Material#valueOf(), was the weirdest bug ever because sysout would return the same object, or atleast felt like they were the same
i didnt do them at the same time ofcourse
weirdchamp tbh
If someone knows, let me know 
String
Then question would be, can be any of them? boolean or string?
String..
"true"
but question was: can it be a boolean too?
hikariConfig.addDataSourceProperty("useSSL",true)
or it must be a String always and boolean is not supported
Just make it "true"
I mean if all it allows is strings, then yes

does anybody know where LivingEntity#getKiller() get it's data from and how to manipulate it? (not using paperspigot 😢)
EntityDamageEvent or some shit?
Hey so I am sending the PacketPlayOutPlayerInfo packet to client and setting them to sepctator so their name shows up in tab as greyed out. But this will make it so the player cannot use their hotbar and it will set their flyspeed and such. How would I fix this (eg. revert them to survival abilities and still keep the tab changes)?
Send the packet to all players except themselves? 🤔
when I have a file named something.log how can I (if the file exists) compress that delete it and create a new one all from within Java? similar to how minecraft does it with the log files
if file exists
compress it
delete it
etc
okay okay, now hear me out
how do I compress it xD
I only found solution where people use Processes to use zip commands in Linux
but that's eww
wow its that simple oof fanks matt
Smh Johni
my ult discord forgot which email it was on can i get lil help to figure which one?
does anyone here know how to use NoteBlockAPI im having an error
What is your error?
I love you too Matt
If I ask another dumb question I just need to banned honestly 💀 thanks
?not-discord
Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.
in 1.19 is there a way to tell if zombie was natural spawned or from a spawner?
Doubt it, but you can use SpawnerSpawnEvent and put on PDC
THANKS, I will look into that
how do you exactly go about setting up a tab completer for a command registered with the command map
What's your method of registering the command atm?
Since can't you just override the tabComplete method of Command?
I mean yeah but at least my goal here was to do it separately
because I plan on expanding it a lot
this is the CommandManager class where I register them https://paste.helpch.at/civojopode.java
Hello! With the help of DeluxeMenu, I have an exchange of goods on my server (iron for gold, etc.). At night, for a couple of hours, people can freely exchange goods, even if there are none in their inventory. Dup. How can this be resolved? The latest version of the plugin is on Java 11
'gold_ingot':
material: gold_ingot
amount: 16
slot: 2
lore:
- '&7Обмен железа на золото'
- ''
- '&7- Левый клик: обменять &b18 &bзолота &7за &a1 железный блок'
- '&7- Левый клик+шифт: обменять &b144 золотых слитков &7за &a8 железных блоков'
- '&7- Левый клик: обменять &b32 железа &7за &a16 золота'
right_click_requirement:
requirements:
has_item:
type: has item
material: 'gold_ingot'
amount: 16
deny_commands:
- '[message] &cВ вашем инвентаре отсутствует 16 ед. данного товара.'
right_click_commands:
- '[console] clear %player_name% gold_ingot 16'
- '[console] give %player_name% iron_ingot 32'
- '[message] &aВы обменяли золото на железо'
left_click_requirement:
requirements:
has_item:
type: has item
material: iron_block
amount: 32
deny_commands:
- '[message] &cВ вашем инвентаре отсутствует 1 железный блок.'
left_click_commands:
- '[console] clear %player_name% iron_block 1'
- '[console] give %player_name% gold_ingot 18'
- '[message] &aВы обменяли железо на золото'
shift_left_click_requirement:
requirements:
has_item:
type: has item
material: iron_block
amount: 128
deny_commands:
- '[message] &cВ вашем инвентаре отсутствуют 8 железных блоков.'
shift_left_click_commands:
- '[console] clear %player_name% iron_block 8'
- '[console] give %player_name% gold_ingot 144'
- '[message] &aВы обменяли железо на золото'
This is an example of my code
Тебе нужна проверка эсть ли у игрока железо или золото
Из за этого игроки и могут просто обменивать ресурсы
@wide token
так она есть)
в коде же это указано
проблема в том, что ночью в 11-12 часов
внезапно она отключается
и игроки могут спокойно обменивать товары, даже без нужных предметов
я ума не приложу как это вообще возможно
Ааа да, эсть проверка. Не заметил). странная фигня
очень
У тебя случайно нет двух таких менюшек?
в каком плане? Несколько меню от DeluxeMenu?
Да
Ну, типа где можно обменивать ресурсы
А ну это тогда не то
Я думал есть два одинаковых мену и одна сломанная

@grim oasis @icy shadow
» Give the helpers some details
» Ask suitable questions
» Be polite
» Wait
@wide token » Wait
Also wrong channel
So i work w kids and im making a plugin to play amongus in minecraft for them. one of the tasks needs to spawn an armor stand only visible to that player using packets. heres my code, ignore the debug stuff and other fluff. the stand doesnt spawn, anyone know why? btw, the participants class extends player
Hey guys, having some issues with velocity right now
That sucks
People are able to run commands while offline
And it's throwing some errors
Let me get a paste
?paste
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
How tf do u run a command while offline
x2
INFO java.util.concurrent.CompletionException: java.lang.IllegalStateException: Not connected to server!
lol
That's the problem
It freezes the main thread and still processes when the person is offline
But how does that happen in the first place
Anyway this sounds more like a velocity bug than anything else
Yeah, we reported it but it's the only instance of this happening
The server got hard ddosed (1500+ connections per second) yesterday and that's what started it
can someone help me w this
🤔 what version is this on
16.3
Does it run the debug code?
yes and its not null
Try sending the data packet as well.
? as a debug u mean?
it prints both the armor stand and packet
sry for the wierd pic format im at school
private ArmorStand armorStand;
private void spawnStand(Location loc, String customName, Player player, ArmorStand stand) {
if(stand == null) {
ServerLevel level = ((CraftWorld) loc.getWorld()).getHandle();
ArmorStand nmsStand = new ArmorStand(EntityType.ARMOR_STAND, level);
nmsStand.absMoveTo(loc.getX(), loc.getY(), loc.getZ());
nmsStand.setNoBasePlate(false);
nmsStand.setNoGravity(false);
nmsStand.setInvisible(true);
nmsStand.setInvulnerable(true);
nmsStand.setCustomName(CraftChatMessage.fromStringOrNull(StringsUtil.get().colorize(customName)));
nmsStand.setCustomNameVisible(true);
this.armorStand = nmsStand;
}else {
this.armorStand = stand;
}
SynchedEntityData syncedData = armorStand.getEntityData();
List<Packet<?>> packets = Arrays.asList(
new ClientboundAddEntityPacket(armorStand),
new ClientboundTeleportEntityPacket(armorStand),
new ClientboundSetEntityDataPacket(armorStand.getId(), syncedData, true));
ServerPlayerConnection playerConnection = ((CraftPlayer) player).getHandle().connection;
packets.forEach(packet -> playerConnection.send(packet));
}
sorry but do i change w my code from this? im still learning packets
Try sending the teleport and data set packets. (Code above is mojang mapped so adjust accordingly)
setdata packet
(Code above is mojang mapped so adjust accordingly)
ooh ok ty
no
according to screamingsandles 1.14.4+ has mojang mappings
1.17 is when spigot did mojang mapped and had a remapping plugin for maven.
The mappings were available, but not used by spigot/paper until 1.17
You can still use the mappings to check what the values are, it's just not as nice as for example using paperweight
it spawned 😄 tysm!
np
Happy to help
so the mappings are unusable other then to check for stuff?
i see.
?, also tabComplete from commandMap is for tabcompleting for the player, not to set the tab completion results
how can i "summon" a warden's sonic boom? what even is it, an entity???
i'm tryna set a material rn in spigot 1.8.9 but a lot of stuff just isn't showing up. anyone know why?
what material you trying to set?
SPIDER_EYE should show up
Material.SPIDER_EYE does show up in the material enum for 1.8.8
You can, but just a heads up theres a lot of things to "summon" : go here to look up the documentation https://hub.spigotmc.org/javadocs/bukkit/ : in the search bar type in "sonic" to pull up the list. From whats available you can grab the particle effects, sounds and damage event. With those you could likely mock the sonic boom event. Unfortunately, the actual attack isnt a projectile that can be used for simplicity.
im trying to add placeholders to a plugin and have this code which i based off the wiki but they dont seem to be ingme even though papi says the plugin was registered and shows up in /papi list is there something im missing?
https://bin.birdflop.com/merewikosu.java
what's the placeholder you're trying
ive tried %karma% and %wins% as well as %deaths%
they all only return the string again
You need to put the expansion identifier in there as well, so %sabotage_<placeholder>%
yep i guess that would do it 
What do you mean by "set the tab completion results"?
any thoughts on transferring files/ a whole world from one server to another linked by bungee
maybe ftp?
Is there a way to detect if a player has opened it own inventory (1.16+)
Currently I have tried
Listening for InventoryOpenEvent (seems to be client side)
Checking every tick if the player has an open inventory. This somewhat works but it also closes the chat and leave screen (if I can solved that, it would work but I could not find any ways to do so
Checking for Achievement.OPEN_INVENTORY (no longer supported in 1.16)
Listening for PacketType.Play.Client.CLIENT_COMMAND packet (did not fire at all)
I don't think so, until they click something it's entirely client sided
Constructor<?> destroyConstructor = Objects.requireNonNull(destroyClass).getConstructor(int.class);
Hello why I receive this error java.lang.NoSuchMethodException: net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy.<init>(int)
Here is the packet parameter public PacketPlayOutEntityDestroy(int... var1)
NoSuchMethodException
yes getConstructror throw this error because he dont recognize the constructor but as you can see on the last code it should work ?
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import static testingplugins.testingplugins.Items.oak_log;
public class Events implements Listener {
@EventHandler
public void onPickup(EntityPickupItemEvent e) {
if (e.getItem().getItemStack().equals(new ItemStack(Material.OAK_LOG))) {
e.getItem().setItemStack(oak_log);
}
}
}```
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class Items {
public static ItemStack oak_log;
public static void init() {
createItems();
}
public static void createItems() {
ItemStack item = new ItemStack(Material.OAK_LOG);
ItemMeta meta = item.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("§f§lCOMMON");
meta.setLore(lore);
item.setItemMeta(meta);
oak_log = item;
}
}
help
It only works with a 1 amount of oak log
how can I make it work when I pickup a stack of the oak log
use isSimilar instead of equals
tho im trying to get a better way
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class Events implements Listener {
@EventHandler
public void onPickup(EntityPickupItemEvent e) {
List<String> lore = new ArrayList<>();
lore.add("§f§lCOMMON");
if (e.getItem().getItemStack().isSimilar(new ItemStack(Material.OAK_LOG))) {
e.getItem().getItemStack().getItemMeta().setLore(lore);
}
}
}```
I ended up with this
and idk why this isnt working
Is the listener registered?
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Plugin has been enabled");
// Plugin startup logic
}
@Override
public void onDisable() {
// Plugin shutdown logic
getServer().getConsoleSender().sendMessage(ChatColor.RED + "Plugin has been disabled");
}
}```
Looks registered lol. Add debug.
public void onPickup(EntityPickupItemEvent e) {
if(!(e instanceof Player p)) return;
p.sendMessage("your text");
}
Bukkit.broadcastMessage("your text");
Bukkit.getPlayer("your name").sendMessage("your text")
Bukkit.getLogger().info("your text")
<Main>.getLogger().info("your text")
System.out.println("your text")
its going to print that in the console and going to broadcast in chat?
but what
how is it going to know the error
or is it to check if the plugin is actually working or not
Its not checking for a specific error its showing; 1 that the code is running, 2 what ever info you add in the text such as the item, type, entity etc...
do u know if the sonic boom has a delay before it dmgs the player? like time for it to reach the player? or does it just instantly do damage when the sonic boom is shot?
and how would i use EntityDamageEvent.DamageCause? could i not just do 10 damage to the player?
It’s nearly instant, or you could set it to like .25 second delay. Damage cause would also be used to tell the player how they died if you cared about that, otherwise yes, you could just hit them for 10 damage.
👍
first of all
second I mean that when you do tab when typing a command suggestions appear right?
thats the tab completion
I want to set those results when using my commands
but tabComplete from commandMap its for doing tab complete
not setting the results
what do you think "doing tab complete" vs "setting the results" each means?
uhh well
what the name says lmao
I mean I think that it does so because of the result it gives
'First of all' people reply when they can 😉
:pog:
I agree 
you "set the results" when you are "doing tab complete"
you return the list of completions in that method
that is literally what the method is for
client notifies server "I'm typing this command, please give me suggestions", server calls your command tabComplete, command returns list of suggestions, server sends that to client
how does chat preview work? is it anything similar to tab complete?
I'm assuming it functions in a similar way
is it some sort of event?
I don't think the API supports it yet
aw dang
is using a 3rd-party api the only way mojang intended it to be used?
or is there like a way to set it in-game
Idk exactly how mojang wants it on vanilla server
But spigot/paper will add api for it soon
👍
Tbh i don't even know if you can customize the chat on the vanilla server 
And btw there is something called timezones
you can now with data packs 
Oh true I sometimes forget that exists lol
wait so like that method is for getting a list of all possible suggestions for that command?
I guess so
Having some issues with velocity:
So basically this server I admin on is having some major issues with velocity where basically they are getting attacked (have been being attacked for 3 days straight). Whenever someone sends chat or commands, it completely blocks the main thread for like 30 seconds. Does anyone know how to fix this/stop the attack?
what do you think it's for ?
yes but where do I send those possible completions lmao
because
it returns those
right?
or am I stupid
You're supposed to return a list of strings in the tab complete method, those are the completions
in the command overriding the Command one?
the server calls it
well, yes, where else? that's the only place the server knows where to call
it calls tabComplete on the corresponding command
Bring this back up, got locked past
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import static me.none030.itemrarity.Items.LoreVariable.*;
public class ItemRarityEvents implements Listener {
@EventHandler
public void onPickup(EntityPickupItemEvent e) {
if (e.getItem().getItemStack().getItemMeta().getLore().isEmpty()) {
e.getItem().getItemStack().setItemMeta(itemLore.getItemMeta());
}
}
}
why does this not work
uh what
Where is the debug code?
no errors
It's not specific to errors 🤦 it's to see what your code is doing or even reaching your code
do you want the full code?
Yes
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class LoreVariable {
public static ItemStack itemLore;
public static void init() {
createItems();
}
public static void createItems() {
ItemStack item = new ItemStack(Material.OAK_LOG);
ItemMeta meta = item.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("§f§lCOMMON");
meta.setLore(lore);
item.setItemMeta(meta);
itemLore = item;
}
}
import me.none030.itemrarity.Events.ItemRarityEvents;
import me.none030.itemrarity.Items.LoreVariable;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public final class ItemRarity extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new ItemRarityEvents(), this);
LoreVariable.init();
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Plugin has been enabled");
// Plugin startup logic
}
@Override
public void onDisable() {
// Plugin shutdown logic
getServer().getConsoleSender().sendMessage(ChatColor.RED + "Plugin has been disabled");
}
}
ignore this item
im just using it's meta data
Does the plugin actually start?
yes
where do you define itemLore?
here
So add debug code to the event and check if it's even running.
... and the error?
Txt please
its too big
Your array is empty at some point
which
how
this detects if the item lore is empty
and if its empty it adds a lore
thats what im trying to do
Well isEmpty isn't gonna work because your passing in null not a empty list
Dw about it, the paste is the right way to send things, you're doing it right
Or rather check if it's null. Not if the list is empty
why? https://srnyx.sucks-at.life/qA087j5E9c.png https://max-is.very-stinky.com/idea64_Kc7a4mDt5l.png
private final boolean ia = itemsAdderInstalled();
public static boolean itemsAdderInstalled() {
return Bukkit.getPluginManager().getPlugin("ItemsAdder") != null;
}```
Why what
why is it always false
Oh because you need to separate the 2 statments
i provided what ia is in the block code, its possible to be true
What is itemadderinsalled
thats what ia is:
private final boolean ia = itemsAdderInstalled();
No ik that
Well either intellij is tripping or you're wrong
Can you show the full code
But what does the itemAdderInstalled function do
He is too busy in the crib playing fortnite with your grandma
return Bukkit.getPluginManager().getPlugin("ItemsAdder") != null;
checks if itemsadder is installed
its used in other parts of my plugin and its been true (when itemsadder is installed ofc)
DamageManager.java:```java
private final boolean ia = Main.itemsAdderInstalled();
/**
* Damage reduction for helmet
*
* @return The amount of damage reduction
*/
private double helmet() {
if (inv.getHelmet() == null) return 0.0;
final Material material = inv.getHelmet().getType();
// problem code v
if (ia && inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;
if (material == Material.DIAMOND_HELMET || material == Material.NETHERITE_HELMET) return 0.12;
if (material == Material.GOLDEN_HELMET || material == Material.CHAINMAIL_HELMET || material == Material.IRON_HELMET || material == Material.TURTLE_HELMET) return 0.08;
if (material == Material.LEATHER_HELMET) return 0.04;
return 0.0;
}````Main.java`:```java
/**
* Checks if ItemsAdder is installed
*
* @return {@code true} if ItemsAdder is installed, {@code false} otherwise
*/
public static boolean itemsAdderInstalled() {
return Bukkit.getPluginManager().getPlugin("ItemsAdder") != null;
}```
Yea
u mean if (ia) if (helmet... = custom...)?
yeah that gets rid of the error but it doesnt make sense why it wouldnt work the other way
Well && is funky in java
no it's not lol
when i use context actions to merge it gives me what i had before
yeah because it doesn't matter
yea thats what i had thought
If ia is false then it doesn't matter which you do
That is odd, but you probably wanna use isPluginEnabled rather than getPlugin != null anyway
does that account if the plugin fails to enable?
yes
alright good, i was having problems with getPlugin != null related to itemsadder not enabling
if i click Remove 'if' statement extracting side effects:
if (ia) {
inv.getHelmet();
CustomStack.getInstance("vanadium_helmet").getItemStack();
}```
ok intellij says this is ok:
/**
* Damage reduction for helmet
*
* @return The amount of damage reduction
*/
private double helmet() {
if (inv.getHelmet() == null) return 0.0;
final Material material = inv.getHelmet().getType();
// problem code v
if (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;
if (ia && inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;
// problem code ^
if (material == Material.DIAMOND_HELMET || material == Material.NETHERITE_HELMET) return 0.12;
if (material == Material.GOLDEN_HELMET || material == Material.CHAINMAIL_HELMET || material == Material.IRON_HELMET || material == Material.TURTLE_HELMET) return 0.08;
if (material == Material.LEATHER_HELMET) return 0.04;
return 0.0;
}```
+😳
I don't think that can succeed
ia && iv.getHelmet() shouldn't even be possible I don't think
Well I don't know what ia is, but I don't think inv.gethelmet returns a bool
yea ia and inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack() r both booleans
this is all the original code
if i put ia after inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack() it works fine...
if (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack() && ia) return 0.16;```
why bruh
Yeah that makes sense
Order of operations of sorts
If you really want ia first use parenthese
i tried
ia && (#getHelmet == Itemstack)
for what?
Operand #1 of and-chain is false
Condition 'ia && (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack())' is always 'false'
Then ia always returns false
it doesnt tho
public static boolean itemsAdderInstalled() {
return Bukkit.getPluginManager().isPluginEnabled("ItemsAdder");
}```
i use it in other parts of the plugin too
So are you saying (#getHelmet == Itemstack) && ia works correctly though?
with and without parentheses yes
but i need to check for ia before the other thing
That's some goofy shit
it also says that if (ia) if (getHelmet == ItemStack) is fine
@dark garnet
This is a really stupid suggestion, but try single & instead of double
== on ItemStacks sounds sus
ik ik i gotta fix that later
fixes it but then my code analyzer tells me not to use &
Correct this "&" to "&&" and extract the right operand to a variable if it should always be evaluated.
Oh interesting
final boolean custom = inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack();
if (ia && custom) return 0.16;```
Anyway, I think that's your solution
this also works (following what code analyzer says)
but...
that wont work
since i have to check for ia before doing any customstack stuff
imma just do this:
if (ia) if (inv.getHelmet() == CustomStack.getInstance("vanadium_helmet").getItemStack()) return 0.16;```
That’s equivalent to &&
well intellij doesnt yell at me when i use it soooo
and && should be fine but intellij says no
If IntelliJ says no, there’s a reason for that
I think there’s an option to trace back where a value comes from
then it should also be saying no for if (ia) if (...)
If the dataflow analysis found a TOP value somewhere, you can trace it back
And if it tells you that something is false, then it found a TOP value somewhere
TOP?
An unambiguous value that can have exactly one state
this is all the code btw
imma try using this for now:
if (ia) {
final CustomStack custom = CustomStack.getInstance("vanadium_helmet");
if (custom != null && inv.getHelmet() == custom.getItemStack()) return 0.16;
}```
IridiumColorAPI can't have more than 1 step colors and bold, strike, underline, etc right?
vault have a booster?
No
how i can create a head with custom value?
how can I make Module A of my Gradle Multi-Module Project be dependent on Module B and wait for that to finish Build first
I have this in my Submodule
tasks.register("copyCreator") {
dependsOn("shadowJar")
copy {
from("build/libs/PebbleConfigCreator-all.jar")
to("src/main/resources/PebbleConfigCreator.jar")
}
}``` But the Problem is, I get this:
```Could not determine the dependencies of task ':shadowJar'.
> Could not create task ':PebbleConfigCreator:copyCreator'.
> baseDir may not be null or empty string. basedir='null'```
task<Copy>("copyJarToServer") {
from(shadowJar)
into("./server/plugins")
}
This is what I use to move the jar to the plugins folder
@marble nimbus
Ah, to depend on the execution of a task of another module, you have to use dependsOn(module:task). It will invoke module:task and then your task
yea I managed to do it, thanks alot
does ShadowJar exclude jars from the resource Folder?
Hello good afternoon! How can I show my items in quantity in the gui menu? Tried: quantity: 10 more didn't work?
material: LIGHT_BLUE_STAINED_GLASS_PANE
quantity: 10
slot: 20
priority: 1
update: true
hide_attributes: true
display_name: '&aEXPANDIR 10'```
amount: ?
also this is a #general-plugins question, not a development question.
the deluxemenus wiki is here https://wiki.helpch.at/clips-plugins/deluxemenus
Is there an easy way to access a relocated class?
so like cast a class that could be any package to the original class's package, and work with it from there
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scheduler.BukkitTask;
public class SkillsStats implements Listener {
@EventHandler
public static void onJoin(PlayerJoinEvent e) {
int mana;
mana = 100;
int health;
health = (int)e.getPlayer().getHealth();
String message = health + " " + mana;
String name = e.getPlayer().getName();
Player player = Bukkit.getPlayer(name);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
}
how can I repeat this task
I want to create a permanent action bar
Search for Bukkit scheduler
have a runnable, also ew
why is no sound being played when i use Sound.ENTITY_WARDEN_SONIC_BOOM?
i tested with another sound and it works
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_WARDEN_SONIC_BOOM, 1, 1);
ping me if u reply
it doesnt even come up in /playsound
entity.warden.sonic_charge
yea it doesnt show up
no tab complete for it: https://srnyx.needs.rest/java_Ty9iG7Rt5y.png
and when trying to play it, nothing is played, and nothing in subtitles either
how can I get the player name here
Skills plugin;
public SkillsStats(Skills plugin) {
this.plugin = plugin;
}
public int mana = 100;
String name = Bukkit.getName();
public int health = (int)Bukkit.getPlayer(name).getHealth();
@Override
public void run() {
String message = health + " " + mana;
Player player = Bukkit.getPlayer(name);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
}```
as this doesnt work
Bukkit.getName()?
^^
With reflection, how does one cast an instance of a class (eg. com.package.testclass) to a relocated version of the same class (eg. net.example.testclass), since the original instance could have any package, but I need to work with it like it's an instance of net.example.testclass, since it's the same class (atleast, in terms of duck typing)
you don't
they are completely different classes with different signatures
that's like saying "Oh, LuckPerms API has a UserManager class, why can't I use my class also named UserManager that's in my package instead of that one?", they're different classes that happen to be named the same and have the same methods, but they're still different, you can't cast one to the other
dang, is there a way to emulate a duck typing like situation?
or do I need to manually call methods via reflection?
because that sounds terrible lol
or some cursed classgen stuff
I definitely know what classgen is
programmatic class generation
well I got that, I meant like how to use it
idk
it was in the name lol
you asked
but I'll just use reflection
Mixin moment
well mixin needs runtime support (and that kind of thing is not exactly something that is done out of the box either)
you could pull off some hacky whacky compile-time crap
joe mama needs runtime support
i want runtime support for my life
how to partially shade dependencies on a library (w/ Gradle)?
Wym partially shade?
Shade some dependencies while others are inherited transitively
Exclude those deps
but will they still be inherited transitively?
bcz what I'm trying to accomplish is to remove some of my transitive dependencies from the guy that is shading my library, some of which could be a burden to manage or bcz of conflicts, you know
I know that there are many libraries that do this, I just don't know how they do this
shadow has explicit include/exclude dependency merging
something something documentation
but how do I publish the shadowed jar instead of the normal one (with java-library plugin)?
if it’s for public use don’t
why would you want to publish shaded jars? ultimately it's up to the end library user which distribution method to use, forcing it in a way they may not be interested in is not a nice thing to do
I have my reasons to shade some dependencies in a library
why
stupid dependencies like this: "org.checkerframework:checker-qual:3.21.4"
what about it
secret you’re stopping people from excluding those libraries if they need to
and you're stopping them from other kind of dependency resolution stuff, like version management
it’s really important in public libs that you don’t shade anything in the deployed jar
that's exactly what I want
why?
most of the dependencies will be exposed to the consumer and I'll let them choose what they want to do, but not with all of them
what does that solve
the 1567498 relocations my lib current requires
what is the underlying problem? checker-qual is just annotations ultimately tho
why does your lib require relocations that's like really bad lol
relocating its dependencies emily
hm?
the problem I'm trying to solve is just convenience, I want to remove some of the burder from the consumers
🤨
what is the problem of shading annotations?
they are small, and are already implementation so the consumers never directly depended upon them
well annotations like jetbrains' and checker-qual have no effect at runtime whatsoever (they are not even loaded at runtime so including them in the final runtime jar is pointless), it's compile-time checks (if there is a processor present.. in reality it's IDE support tho)
i mean in the case of those kinds of annotations use compileOnly if you don't plan on exposing them to consumers and it's only for your own build process
but by shading stuff you don't even give them option to choose at all
this man really be relocating jetbrains annotations
I know its possible bcz I already saw many big names doing that, I just wanted to know how 😢
if you don't want them to get the classes, don't publish shaded jars because that will actually let them use the classes, since they are part of your artifact, not transitive anymore
there are ways around that, like shading stuff only on already transitive parts of your lib
wat
the second you shade something, it no longer becomes transitive, it is embedded into your artifact and it is something you ship with your jar, it is not transitive
i can't win against these arguments, but I noneless still want to learn how to do what I've explained
Dependencies in the api configuration won't be shaded because they are, well, considered api contract and are exposed "properly" (i.e. as different dependencies in the dependency graph)
Dependencies in the implementation and runtimeOnly configurations are shaded and not "exposed" in the dependency graph (though the actual classes will be exposed once they are inside your jar file); ShadowJar adds a shadow configuration that has the "original" behaviour of implementation (part of the runtime classpath, not shaded in, not exposed in the dependency graph to consumers)
Should also note that with gradle you can strictly require a specific version of a dependency, so if a consumer tries to use another version, build will fail (ideally with a provided reason you put in too)
Hello o/
i want to make an api for my server so i can use it on my website/discord server
i have seen many peopl use like
api.servername.com/rank/playername or something like that
if anyone knows how or have a video tutorial it would help me a lot
Thanks.
If you want to use Spring, then here's a guide I found: https://spring.io/guides/gs/rest-service/
¯_(ツ)_/¯
With Paperweight, how do I exclude a dependency (specifically adventure in this case as I'm using an older version of Paper while requiring a new version of adventure)?
exclude(group = "net.kyori") doesn't work 😕:
paperDevBundle("1.17.1-R0.1-SNAPSHOT") {
exclude(group = "net.kyori")
}
```but when running `gradle dependencies` I see this: ```
\--- io.papermc.paper:paper-server:1.17.1-R0.1-SNAPSHOT
...
+--- io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT
...
| +--- net.kyori:adventure-bom:4.9.3
🤔
Your own version should have priority I believe
but the thing is that I don't want to accidentally use paper's adventure
since I will also be relocating adventure
You wont
how come?
like player.sendMessage
in other projects I created an extension function
That is not adventure, that is paper api
yes but I'm trying to prevent using paper api
then creating my own extension function for sendMessage
Well, then use spigot ??
I'll prob just use regular paper api without paperweight
going to see if that works
Also, your extension will be shadowed by the actual method
yes but not if the adventure api provided by paper is excluded
since it'd convert to something like BukkitFunctionsKt.sendMessage
Are you sure about that?
public String getChannelNameByPlayer(Player player) {
for (ChatChannel channel : channels.values()) {
if (channel.getPlayerList().contains(player.getUniqueId())) return;
}
}```
how i can return the name of the channel?
i mean
is there any way to get the key of a map having the value?
and use inverse?
yes
okay
When you initialize the class, it implements all the methods of the class, is it necessary?
dont exists xd
it gives me this error
UnknownFormatConversionException
in setFormat()
this is my setFormat
e.setFormat(translate(plugin.getChatConfig().getString("CHAT-FORMAT"))
.replace("{player-name}", "%s")
.replace("{message}", "%s"));```
public void setFormat(@NotNull String format)
throws IllegalFormatException, NullPointerException```
Sets the format to use to display this chat message.
When this event finishes execution, the first format parameter is the Player.getDisplayName() and the second parameter is getMessage()
format - String.format(String, Object...) compatible format string
IllegalFormatException - if the underlying API throws the exception
NullPointerException - if format is null
i fixed it using this
e.setFormat(translate(PlaceholderAPI.setPlaceholders(player, plugin.getChatConfig().getString("CHAT-FORMAT"))
.replace("{player-name}", "%s")
.replace("{message}", "%s")
.replace("%", "%%")));```
but now shows the format without placeholders
import com.connorlinfoot.actionbarapi.ActionBarAPI;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class SkillsStats implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent e) {
int health = (int)e.getPlayer().getHealth();
char heart = '\u2661';
int mana = 100;
String message = "§c" + health + "/" + maxHealth + heart + " " + "§b" + mana + "/" + maxMana;
ActionBarAPI.sendActionBar(e.getPlayer(), message, 100000);
}
public int maxMana = 100;
public int maxHealth = 100;
}```
why is this not working
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.none030.actionbarapi</groupId>
<artifactId>actionbarapi</artifactId>
<scope>system</scope>
<version>1.5.4</version>
<systemPath>D:/ActionBarAPI-1.5.4.jar</systemPath>
</dependency>
</dependencies>```
Figured out that actionbarapi doesnt work in 1.18
why would you even need it
Use adventure @stuck canopy
could you not just do player.sendActionBar(Component.text(""));
might be paper only, not 100% sure
Yes, thats adventure
Im trying to create a permanent action bar
scheduler.runTaskTimer(sendActionBar, 1, 1)
that prob your best bet ^
also realistically it doesnt matter but you should be able to do it async
for some reason it returns false being that the player is in the list
packets are queued sync anyway, the only thing that will happen async is adding it to the queue
public boolean isInChannel(Player player) {
for (ChatChannel channel : channels.values()) {
if (channel.getPlayerList().contains(player.getUniqueId())) {
System.out.println("yes");
return true;
}
}
System.out.println("no");
return false;
}```
a class i created xd
yes
assuming its kinda like a staff chat/clan chat thing? so only certain people are included in the conversation, just assuming
idk how many channels there will be but if there will be a lot it might be good to have a map that is player -> list of channels they are on/channel they are in if they can only be in one
just to avoid looping, not too big of a thing but it might also make your code simpler
but how can I define the player in there
the same way you would define the player for the "ActionBarAPI"
I defined it in a PlayerJoinEvent
adventure?
well there's your player
on join add and on leave remove
thank u
u also
finally I was able to make it work
how can i get all the children keys of a key in a yml file?
ping if reply
getConfigurationSection("key").getKeys(true) true will return even sub path keys of every key under the config section. False will only return the base nested keys under the configuration section.
try {
file.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
}```
Im currently trying to create a config.yml if there isn't one on start up but all it does is throw except
anyone have a good way of doing it?
well.. what does the exception say?
if it's telling you something is wrong, maybe paying attention to what it says might be important
Would I just loop thru that and check if the beginning of the key starts with what I want to get the sub-keys/children of?
well im pretty sure it's something with how i wrote my code is the problem
What is file?
does the parent folder of the file exist?
config.yml
File file = new File("Discord/config.yml");
does this create the parent folder
No you need to create the folder first
dam im dumb
Also I’m pretty sure that puts it in the root directory
You should use Bukkit.getPluginDirectory() or something, I can’t recall what it is exactly, Emily can probably tell u
I'm a newbie so
would the plugin directory be the one i create
cause it currently creates nothing
in your main plugin class you'd have something like this
File dataFolder = getDataFolder();
File config = new File(dataFolder, "config.yml");
dataFolder.mkdirs();
config.createNewFile();
oh i think i got it
before
folder.mkdir();
getLogger().info("Creating new directory for Discord");
} else {
getLogger().info("Found your directory!");
if(!file.exists()){
try {
file.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}```
File file = new File(folder + File.separator + "config.yml");```
is my folder variable wrong?
getDataFolder already returns the plugin's own folder inside the plugins dir
so no need for the rest
that would make it plugins/<plugin name>/Discord
ohhh gotcha lemme change it
I got it to work tysm for your help!
one more problem emily xD
My javaplugin isn't extending to classes
other one
String link = getConfig().getString("Link"); this getConfig() is throwing an error because i need java plugin to be in that class also
I think I'm misunderstanding your question.
Path-1:
Path-1-Sub-1:
Sub-Sub-2: -1
Path-2
Path-2-Sub-1:
Sub-Sub-2: 1
getConfigurationSection("Path-1").getKeys(true) will return ["Path-1-Sub-1", "Sub-Sub-1"]
getConfigurationSection("Path-2").getKeys(false) will return ["Path-2-Sub-1"]
Hopefully that answers your question.
huh
I have a main class with javaplugin extends and I need it in another class
ok
you need to work on your wording a little bit
but
in your main class make a private static <your main class> instance = null
in the on enable method make it equal this
and create a getter
then just use the getter
does that make enough sense?
as a newbie not really ill send you some that i have
return instance;
}```
public Disc(Discord instance) {
plugin = instance;
}```
no
and i thought this might work in my class
what the...
wait
Discord plugin;
public Disc(Discord instance) {
plugin = instance;
}
didn't work tho for my getConfig so def wrong
disc is my command
alr noted for next time mb
would it be easier to move the command just to the main file
no
structure your code just name things as clearly as possible lol
public static Main getMain() {
return main;
}
private static Main main;
@Override
public void onEnable() {
main = this;
hopefully that is clear enough
I'd call it instance rather than main, that's just old code I had on github
yeah i have that already
ok
so where ever you need a java plugin just do Discord.getInstance()
and that should work fine
so what's the issue
i just needed it public
im dumb
