#help-development
1 messages · Page 1787 of 1
No
uhm no, i also decompiled their resource pack it dosn't have any modifcation for player_head
i am also surprised XD
this is the nbt for their special heads
https://pastebin.com/4gGvS7SX
am i right?
Yes
success in spigot, now CatServer's turn
SUCCESS!
the answer is 1:1 comparison with spigot
ty all you guys
Is something like this possible?
private final Map<String, CommandExecutor> commandExecutors = new HashMap<>();
public void addCommandExecutor(String command, CommandExecutor executor){
commandExecutors.put(command, executor);
}
public void complete(){
for(Map.Entry<String, CommandExecutor> entry : commandExecutors.entrySet()){
MainFFA.getInstance().getCommand(entry.getKey()).setExecutor(entry.getValue());
}
}```
Auto register commands
Sure just remember to add the commands to the plugin.yml
I did but it appears as it hasn't been registered when I type it nothing happens
Are the commands in the plugin.yml?
If they are show the code where you're using the add and complete methods
They are
Each command class adds itself to the list on the constructor
And the last thing on the onEnable is the complete
Show the code for it
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
Bukkit.getPluginManager().registerEvents(this, this);
} else {
getLogger().warning("Could not find PlaceholderAPI! This plugin is required.");
Bukkit.getPluginManager().disablePlugin(this);
}
plugin = this;
eventsAuto = new EventsAuto();
commandAuto = new CommandAuto();
loadConfiguration();
getServer().getConsoleSender().sendMessage(getName() + ChatColor.GREEN + " Plugin loaded successfully! " + ChatColor.RED + "<3");
commandAuto.complete();
Alright are the commands added in loadConfiguration?
No, the commands are added on the classes of the commands. For Exmaple
public class SetSpawnCommand implements CommandExecutor {
public SetSpawnCommand() {
MainFFA.getCommandAuto().addCommandExecutor("setSpawn", this);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(!(commandSender instanceof Player)) return false;
Player player = (Player) commandSender;
etc....
I see
But nothing really happens. I don't think it actually register itl
Now where is the constructor called
registers it
Alright thanks
Yes
found this on a thread:
PlayerDeathEvent#getEntity().getKiller()
hey am still struggling to make this work
Inventory taggui = Bukkit.createInventory(p,45 ,"Tags list :");
List Tagslist = Arrays.asList(Tags.getConfig().getConfigurationSection("Tags").getKeys(true));
for (int i = 0;i<Tagslist.size();i++)
{
String Tag = TagsList.get(i);
ItemStack tagItem = new ItemStack(Material.WOOL, 1);
ItemMeta meta = tagItem.getItemMeta();
meta.setDisplayName(Tag);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.AQUA + "Tag: "+Tag);
meta.setLore(lore);
taggui.addItem(tagItem);
}
p.openInventory(taggui);```
this code does this
want it to display the tags each on as an item
Item.setitemmeta
how to get a list of player's permissions ?
or like check permission.perm.???
and get the ???
for example the ??? is a double
I think some time ~2016, though I could be wrong
rather difficult
enlighten me
Player#getAffectivePermissions or something.
please do let me know if that works as intended
i usually use that, ik it's not the best but it works as intended
like for example using it for a permission based multiplier
Is there a way to access minecraft's loaded usercache.json data or do I need to read it myself?
probs read it yourself
Hi guys, could I use a BucketFillEvent to whenever a player fills a bucket with water it converts the bucket of water into a bucket of lava and the same for lava (a bucket of lava converted into a bucket of water)?
okay, ty
hey i was wondering if this is good way to reload plugin ?
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
plugin.getPluginLoader().disablePlugin(BwCore.getPlugin());
plugin.getPluginLoader().enablePlugin(BwCore.getPlugin());
plugin.reloadConfig();
Tags.reloadConfig();
return true;
}```
Tags is a custom config file
my question is ;
is this needed ? ``` plugin.reloadConfig();
Tags.reloadConfig();
private final ItemStack lavaBucket = new ItemStack(Material.LAVA_BUCKET);
private final ItemStack waterBucket = new ItemStack(Material.WATER_BUCKET);
@EventHandler
public void onPlayerBucketFill(PlayerBucketFillEvent event){
if(event.getItemStack().equals(waterBucket)){
event.setItemStack(lavaBucket);
}else if(event.getItemStack().equals(lavaBucket)){
event.setItemStack(waterBucket);
}
}
Would it work?
I mean, is this the best way to do that?
k, thanks : )
player.spigot().respawn(); is not working when an entity (not a player) is a killer
code:
public static void onPlayerDeath(PlayerDeathEvent e) {
Player player = e.getEntity();
player.spigot.respawn();
}
Is it somehow an issue or im missing something?
Delay with one tick
uh ok
worked thanks
hi so i made a thing where players can create tags but how can i make it so that they can activate the tag from the gui ?
i know i have to use event so i have this so far
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
public class TagsMenu implements Listener {
@EventHandler
public static void onTagPick (InventoryClickEvent event){
Player p = (Player) event.getWhoClicked();
if(event.getView().getTitle().equalsIgnoreCase("§bTags list :")){
if(event.getCurrentItem().getType()== Material.NAME_TAG){
//activate tag
}
event.setCancelled(false);
}
}
}
Tag will work like this
on player message: message format: {prefix}{playername}{tag}":"{message}
Make a hasmap with a player UUID and a string. Then store the tag name and player UUID and when they chat get the value of the player's UUID which will be the tag they choose and set the message to include the prefix.
yeah that's what i thought about after posting that but instead of hashmap a .yml file
and then onevent send message i get it from there
is that good idea ?
On the chat event you will use it.
yes
so like when they click a tag on the gui
this gets created on yml file
(insert actual player uuid):(TAG that they clicked on)```
this will also make it so that if they had a tag selected before it will get changed
and then when they talk the onevent gets UUID and looks what tag they are using
No.
F
The uuid is the player's uuid.
yes
player.getUniqueId()
You'd make it more like
UUID:
tag: ""
The one you edited. Yes that would be the same.
I'm gonna become crazy, I tried soooo much!!
I have a class SocketServer that waits for a socket connection in an infinite while loop and use it like this:
@Override
public void onEnable() {
getServer().getScheduler().scheduleAsyncDelayedTask(this, new SocketServer());
}
I tried runTaskAsynchronously as well, but it produces the same problem.
The socket connections work, but I have no idea on how to end the task onDisable.
getServer().getScheduler().cancelTasks(this);
doesn't work 🤷♂️ ...
I somehow have to end the listener inside the SocketServer; It would also be ok to just to break it, no data can be lost that way.
||would help but i am still noob and i dont understand what any of this means srry||
oh ok
how is that? could you give me an example? XD
@austere cove You're online and have a cool pfp, I hope rn you're the 40% computer nerd cuz I wish you can help me 🙏
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
EntityEquipment equipment = entity.getEquipment()
From there you can do for example equipment.setBootsDropChance();
Well
with?
A socket server is only an endpoint, and ideally you’d have a thread per accepting socket, then you also have some sort of shutdown signal which the iteration inside every thread depend on @snow latch
Take a peek here
Wrote that example not too long ago
How could I do that?
Ahh
Also I use an atomic boolean as opposed to a normal boolean due to atomicity
But you could really just use a volatile boolean variable if you want
Also, that example doesnt handle management of resources (like closing them) afterwards
Whats the BlockingDequeue?
A queue is a first in first out data structure
A dequeue is basically a bidirectional queue
Blocking means that you can await for some other thread to supply an element to the queue
and block until another thread removed an element
That too ^
which is neat, because you can wait for the queue to have space again
they asked a question
^
getServer().getScheduler().scheduleSyncRepeatingTask(...)
returns an int - the task's id.
Save it in a variable:
int taskID = getServer().getScheduler().scheduleSyncRepeatingTask(...)
You can then use that taskID to cancel the task:
getServer().getScheduler().cancelTask(taskID);
fyi it's Deque not Dequeue
Deque stands for "double-ended queue"
Hey, I 've been struggling to make a custom snowball that explodes when it touches sth....... but a couldn't a way to check for snowball NBT when is launched without checking the mainhand.
Get the uuid
hello is there anyway to get a player's Node from string in luckperms api ?
an existing node
Cause I'm new at spigot could you explain it more
On ProjectileLaunchEvent, you put pdc onto the projectile entity.
and listen for ProjectileHitEvent, if the entity has pdc that you put, make it kaboom
Ty, I 'll try it
hey so am working on this and this is my code so far ```package online.shakiz.BwCore.Events;
import online.shakiz.BwCore.BwCore;
import online.shakiz.BwCore.files.TagsManager;
import online.shakiz.BwCore.files.TagsPlayerData;
import online.shakiz.BwCore.utils.utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.plugin.Plugin;
import java.util.UUID;
public class TagsMenu implements Listener {
private TagsManager Tags;
private TagsManager PlayerTag;
private static BwCore plugin = BwCore.getPlugin();
@EventHandler
public static void onTagPick (InventoryClickEvent event){
String prefix = utils.chat(BwCore.getPlugin().getConfig().getString("prefix"));
Player p = (Player) event.getWhoClicked();
Plugin PlayerTag = (Plugin) new TagsPlayerData(plugin);
UUID uuid = p.getUniqueId();
if(event.getCurrentItem().getType()== Material.NAME_TAG){
PlayerTag.getConfig().set("Tags."+uuid ,event.getCurrentItem().getItemMeta().getDisplayName());
p.sendMessage("§bavailable Tags:");
}
event.setCancelled(false);
}
}
but when i clic on the item it does nothing
and there's no errors and i double checked multiple times if i registred it and it is
keep to java conventions and make the first letter of a variable not capitalized
wdym
doesnt matter rn. ill explain later
what do you want it to do anyway
youre clicking on a nametag in an inventory and want to send the player the message "available Tags:"?
event handler is there
just make the method non static
see if that does anything
saveDefaultConfig();
BedWars.registerEvents(new TagsMenu());```
this is where its registred
?
you mean eventHandler ?
i tried to move it up and it gave an error
have you tried debugging it?
put this
p.sendMessage("CP1");
at different points in your code with different numbers to see where it fails and where it gets to. has helped me out a lot
oh ok
mainly in front of and after if(){}
are there any other ways increment player health other than the .setHealth method
you have to set the Attribute of a player to a higher value
if you want the player to have extra hearts as I understand it
no just healing the player
why dont you want to use that method?
sethealth sets players health, not max health
ok explain bit by bit what you want to do.
so set health value must be from 0.0 to 20.0
unless you change the max health attribute
i wonder whether there are any other methods to heal the players
so you want to heal the player but not increase the max hp?
yes
none of the messages were sent ...
setHealth() seems like a perfect solution to that
where did you put them?
basically everywher
what class, what places? send the code
String prefix = utils.chat(BwCore.getPlugin().getConfig().getString("prefix"));
Player p = (Player) event.getWhoClicked();
Plugin PlayerTag = (Plugin) new TagsPlayerData(plugin);
UUID uuid = p.getUniqueId();
p.sendMessage("CP1");
if(event.getCurrentItem().getType()== Material.NAME_TAG){
p.sendMessage("CP12");
PlayerTag.getConfig().set("Tags."+uuid ,event.getCurrentItem().getItemMeta().getDisplayName());
p.sendMessage("§bavailable Tags:");
}
p.sendMessage("CP1");
event.setCancelled(false);
}```
are you getting errors in console?
no
the problem is that it doesnt get detected that the health has increased, but it detects it as if it would just chnage
what do you want to detect it with?
Yeah always get that term wrongly
other plugin, which is not created by me
If you need help remembering it, just think of the word Dick when you need to talk about double-ended queues 🧠
without knowing the implementation of that plugin its hard to track down the problem imo
hey, i've noticed my tabcompleter starts the completion from the start of the list i provided even if I'm already writing something and i press tab
yes

how can I make it finish whatever im writing if it is a valid completion?
to make it easier, what plugin do you want to work with?
StringUtils.copyPartialMatches
Or StringUtil, don’t remember
one that detects health healing and getting damged and stuff
so i'd have to loop my tab completions
No one said that
I dont really wanna go on a goosechase for hints so please just drop some of your code in here or give more information. does the player actually get healed when you want to?
no yeah well, nah its ok, the primary question was whether anyone was aware of other methods of healing players
ok thats something to work with
no need to check further down the path
im not finding that event tho
Might be entity
Could make a PR to have the method fire the event I suppose
i mean so far that would be unnecessary, but ill think about it later on :)
how to send warning to console? just sendMessage()?
You can use it for console too
Bukkit.getConsoleSender().sendMessage()
ah
Use plugin.getLogger.warning
^
Or warn, whichever it is
something along those lines, am not sure either xD
thanks
On PlayerDropItemEvent, how can i replace the item and cancel the drop?
PlayerDeathEvent#getDrops()
xD
i read it as death for some reason
gimme a second
getItemDrop gets the item entity
right now i do e.getPlayer().getInventory.setItem(...) and then e.setCancelled(true); , but no matter in what order, it moves the old item to the first slot instead of replacing it
i could just not cancel and set the item entity to null, right?
does that work? xD
Maybe
If it’s an Item not an ItemStack you can use .remove
yea the method returns an Item
You can also modify it with Item#setItemStack
^
how can i find out which slot the itemstack was dropped from?

what am i doing wrong?
Any recommendations for good scoreboard API's or something?
You can't add the same attributes multiple times. Why are you even looping???
oh im stupid
youre totally right
im just drained out today
i just forgot to delete it since first i tried adding a modifier multiple times, and found out that doesnt work, but i handled that already
Eh it happens
Utils.Test(event.getPlayer());
}, 3L);
}
}```
it does this after like
a minute
i want it to do it after 3 ticks
how do i fix it
That will run after 3 ticks
thag?
Typo :)
what do i do make it after 0.5 seconds
10
20 ticks = 1 sec
math :)
ty
So i did
player.setWalkSpeed(0);
player.setFlySpeed(0);
But the player can still sprint-jump and swim.
How can i stop him from doing that?
Canceling the move-event isnt an option as that will stop any physics from moving the player
i see
and swimming?
water should still move him, so canceling moveevent if in water doesnt work
you can apply jump boost effect with level 127 to prevent player from jumping
i basically just want to disable the wasd and space controls
so the player cant move by himself, but can be moved
how do i get the region name at player
from worldguard?
ye
@digital rain you are using the same modifier multiple times
Can you make the player ride a mob without him actually sitting down?
but why
cuz i want to stop him from being able to move
making him ride an entity is the only good way for that
but then it makes him sit
which i dont want
try to force enable and disable swimming for player
i dont think it will work but give it a shot
wym by that? is there a function?
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>authlib</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>2.3.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>```
did you reload your pom changes?
it worked?
i can extend Placeholder but not PlaceholderExtension
it's PlaceholderExpansion
nope
ima just try restarting my ide
👍
yeah, IntellIj is weird
Question, so I am trying to make this work but for some reason it wont.
public class CommandAuto {
Map<String, Class> cmds = new HashMap<>();
public void addCMD(String command, Class c){
cmds.put(command, c);
}
public void complete() {
for(Map.Entry<String, Class> entry : cmds.entrySet()){
try {
MainFFA.getInstance().getCommand(entry.getKey()).setExecutor((CommandExecutor) entry.getValue().new);
}catch (Exception e){
e.printStackTrace();
}
}
}
}
This is suppose to auto register any commands I add there
and I add this command when I initialize the class
public class SetSpawnCommand implements CommandExecutor {
public SetSpawnCommand() {
MainFFA.getCommandAuto().addCMD("setspawn", this.getClass());
}
but this won't work at all
entry.getValue().new this shouldn't even compile
oh
ok well 1.
don't use newInstance for something so small
it is a very expensive operation
(as is most of reflection)
Oh okay got it, but this would only run at the onEnable once
- the code in your constructor is only run when
newis called on that class
Is the SetSpawnCommand ever instantiated?
so, either way
I'd recommend just making a util method in your plugin class called register or smthn
that takes in a command name and an instance of a command executor
bc this is a very messy, inefficient way to do things :p
I'm confused to why you collect them all then register them? Why not just register them in one go?
meow
I actually hated doing this and found a worse one on the spigot website. What I want to do is just auto register the command or when it is initialized but I guess its a bit messy to make I have tried different options
How would I do that Mike>
You could do that with actual reflection
?
Well if you implement classpath scanning + reflection it'd be possible yeah, but that's maybe a bit advanced for someone who's clearly a beginner.
Brother I used that yesterday I am telling you that I tried more than one option
return when (params.lowercase()) {
"level" -> "${playerData.globalLevel}"
"kills" -> "${playerData.kills}"
"deaths" -> "${playerData.deaths}"
"streak" -> "${playerData.streak}"
"bounty" -> "${playerData.bounty}"
"experience" -> "${playerData.globalExp}"
"levelup_experience" -> "${Util.globalLevelupExp(playerData.globalLevel)}"
"levelup_progress_bar" -> Util.legacyProgressBar(playerData.globalExp / Util.globalLevelupExp(playerData.globalLevel), 20)
else -> null
}``` is there a way to do something like this in java instead of just repeated if, else if conditions?
but not even then
switch
nice Kotlin tho
its a friends 😬
starting to learn how much easier you can do stuff in kotlin over java
anyway lemme just hand-convert that to Java lmao
switch (params.toLowerCase()) {
case "level": return "${playerData.globalLevel}";
// insert other cases here
default: return null;
}
or, if you use newer versions, you can actually shorten it to
do i need to use a break if the case is 1 line?
switch can return and object in later java versions.
I think this is the syntax:
return switch (params.toLowerCase)) {
case "level" -> "${playerData.globalLevel}";
default -> null;
}
yes
otherwise you get switch fall-through
@spare marsh Something like this would work
public void register(CustomCommandExecutor customCommandExecutor) {
this.getCommand(customCommandExecutor.getName()).setExecutor(customCommandExecutor);
}
You'd still need to run a new xyz.
Personally I have a base class that supers this register method and then I just need to do new XYZ() and it auto registers it. Eventually I switch back to reflection
wait what if the action in the switch is a return?
then no
return will end the method, therefore no fall-through cannot occur
Got it, yes I have been trying more than one option but Ima try this if not then I'll just do it like I was doing it at first.
thank you
👍
alr so now that i have this
public class Placeholders extends PlaceholderExpansion {
@Override
public String onRequest(OfflinePlayer player, String params) {
switch (params) {
case "guild": return "text1";
case "guildRole": return "text2";
case "guildMemberCount": return "text3";
case "guildMemberCountCap": return "text4";
} return null;
}
@Override
public @NotNull String getIdentifier() { return ""; }
@Override
public @NotNull String getAuthor() { return "wally"; }
@Override
public @NotNull String getVersion() { return "1.0"; }
}```
when does onRequest get requested?
hewwo
PlaceholderAPI.setPlaceholders(player, string); ?
on request?
yeah does it get requested when you use setPlaceholders on something?
i think when you set ones it checks for your code
that's for placeholderapi support
):
Pssst, DMs
🙄
it is also linked on their github https://github.com/PlaceholderAPI

i dont understand di when you have multiply classes calling super(plugin) so all those classes pass the same instance and the parent instance will only change the first time
whats the difference between return; and return void;
return actually works and return void gets you yelled at
I'm not entirely sure yield even exists anymore tho.
It was part of the original proposal but I see code that doesn't use it.
By the way bc I like to ramble I'll explain void and null
void is basically the absence of a type
null is the absence of a value
null is implicitly everything too though
(since you can cast anything to null, BUT null is still technically not of that thing's type, it can just act as it)
(so, small language quirk, even after casting null to something, that something will fail instanceof checks no matter what as long as it is null)
what math am i doing wrong
if (x <= 1 && y == 0) {
sender.sendMessage("§cYou must have more than 1 life and they must have 1 or more lifes");
}```
all of it
x is the lives the sender has
y is the lives the receiver has
if the sender has 1 life they cannot send
well if you need more than 1, don't use <= as that means "greater than or equal to"
if the receiver has 0 they cannot receive
if i do x < 1 if they have 1 then what does it return
because it's not less or greater
false right?
because it will only return true if it's less than
aight so currently
in your code
if:
x = 0 - false
x = 1 - true
x = 2 or higher - true
yes
the second case, = 1, is because of <=
you're checking "if x is greater than or equal to 1"
when you should be checking "if x is greater than 1"
so, x < 1 should work
ok fucking cool
I don't care about what your plugin does
just fix your code lmao
whats the best way to empty a string builder? i saw setLength(0)
just replace the instance with a new one
it's still going to allow it
no, it wouldn't
isnt that just feeding the gc?
it's pretty much equivalent to setting the length to 0
hmm
like sure there's a small bit of extra GC action
but actually doing a setLength might be more expensive
as it possibly has to copy the underlying array into a smaller one
yea i saw the Arrays.copy
I haven't looked at the impl
yeah copy is a bit slower than new
so the GC impact is negligible
if you actually wanted the most performant option, it would be storing a char[] yourself
but that's a bit more error-prone and hard to read
how the f does it know its going to be changed?
oh
yeah you can't modify variables within lambdas
this is a limitation of the fact that lambdas are just syntactic sugar for private methods
and as such, cannot modify a reference passed to them
not setting the placeholders
also should i store something in a list or a set when i dont need a .get()?
Set
List is the only interface that implements get
But Set is faster for iteration and contains
nvm it has
Since ArrayList has to loop over the underlying array.
Which is an O(n) operation.
meanwhile HashSet should probably be O(1) when it comes to contains but I don't know, haven't looked at the implementation.
It is in best case O(1) ye
What does O(n) mean
O(n) where n = size of the collection
Ah
like f(x) = ax
e.g. scaling complexity, where more elements = a slower operation
Meanwhile O(1) is constant time
yuh, iteration at O(1) wen 
yeah lol
if you utilized concurrency
I mean okay for singleton collections
but that'd be very heavy for processors
technically O(1)
(oh yeah btw HashSet can be much slower if equals/hashCode aren't implemented properly, just a bit of a PSA for y'all)
reminds me of the 1.8 anti-hack servers that start a new thread for some Math.pow calculations because async
...what the fuck? lmao

bruh
idk, I mean time complexity only concerns the amount of operations right?
fixed size list
duh
Yeah can't loop through a list at o(1) that literally makes no sense
?paste
have any ideas for a report comand that even a toddler can write?
cause idk if a 3rd grader can write /report player_name
how badly do you want 3rd graders to be able to write it?
just make an alias to the command /report to be in their native language
that could be easier
shorten it to /sud
let me guess... that means something weird in that language?
i meant the shortened version "sud". google isnt telling me anything tho so it should be fine
np. if you need help implementing just say so
without the []
actually nvm
i need them?
it actually is with the [] my bad
no worries
only ever used one alias
if the command class was set up correctly from the start you dont have to put in anything else
np
how do I accept a persistantdatatype in a method
my placeholders i made don't seem to be working
public class Placeholders extends PlaceholderExpansion {
Data data = new Data();
@Override
public String onRequest(OfflinePlayer player, String params) {
switch (params) {
case "guild": return data.getGuild(player);
case "role": return data.getRole(player);
case "memberCount": return String.valueOf(data.getMemberCount(player));
case "memberCountCap": return String.valueOf(data.getMemberCountCap(player));
case "level": return String.valueOf(data.getLevel(player));
case "exp": return String.valueOf(data.getEXP(player));
} return null;
}
@Override
public @NotNull String getIdentifier() { return "Guilds"; }
@Override
public @NotNull String getAuthor() { return "wally"; }
@Override
public @NotNull String getVersion() { return "1.0"; }
}```
hmmm
i guess it will be %Guilds_guild%
fix the caps
and btw
is the placeholder registered ?
in main class new Placeholders().register()
onEnable
im getting an error "Could not pass event PlayerMoveEvent to ~~filename~~
org.bukkit.event.EventException: null
does anyone know what could be causing it?
im guessing theres a null pointer exception being caused in a playermoveevent
do errors get stored anywhere outside of console print?
not sure. maybe in the log. can you reproduce the error?
yeah
ok nice
Yes they are in the log
console doesnt show the whole error I can just send what I have
ill check there
in logs it says "...at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.17.1.jar:3238-Spigot-6c1c1b2-9217b52]
... 18 more" so ill send what I have
just send the entire error from the console. Ill get you an example
oh hold on in logs its showing more than console, enough for me to see which variable is null
https://paste.md-5.net/obaxamobof.apache this is an entire error so you know what (roughly) youre looking for
very roughly tho as theres many errors you could get
does anyone know whats the difference between GetDefaultValue and the GetValue in an attribute?
I think defaultValue would be the value you start with and value would be the current actual value
so it seems that I have a null teams object, I think all I have to do is run checks on it after initialization
basically check anything that could cause that object to be null
from initialization to changing
so DefaultValue is for the value before any modifiers are applied. Value gives you the value after modifiers apply.
I check for if a team has a certain player, however I think if a team has no players it treats the players container as null.
which is what is causing the error
I wonder if I can provide a placeholder player object to the team that gets deleted after initialization
put it all into an if statement to check wether team has more than 0 players
does generic max health account for absorption or nah
no
no
theres a method in Entity I think to get Absorption hearts
why
not sure, probably gonna screw with some stuff.
tru
setHealth(0) on an entity would have the same effect
deprecated :/
what version are you using
wdym
what version of minecraft are you coding for
setHealth(0) will kill them
1.17.1
Setting max health to 0 will let them live until they get hit
one hit wonder, amirite
i want to ban when they get to 0 health
Hi guys, I am trying to get NBTapi to shade with my plugin but it doesnt work here is my pom.xml so far:
?paste
Are you manually typing your pom xml or smth
why are you defining the shade plugin twice
where
this is my first shade
so i have
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
``` twice?
how do I make a method that acepts PersistentDataTypes?
java.lang.NullPointerException: Cannot invoke "org.bukkit.scoreboard.Team.getEntries()" because "Teams.red" is null
give an example of what youre trying to do
same thing, cant do anything on an empty team object
check wether Teams.red == null instead
PersistentDataTypes (at least the standard ones) are all just basic datatypes really
@eternal night can u help with it why do i get the Cannot resolve com.santapexie.santa_conwand:item-nbt-api:2.8.0 error?
huh ? during build time ?
oh
your dependency is bad
when declaring the dependency, use the actual group id
the "relocation" happens as basically one of the last steps
Like you do with any other method
but when I do ```java
void method(PersistentDataType<Object, Object> persistentDataType)
the input(PersistentDataType.BYTE) causes an error
T,K?
ok ill try
that just causes an error in the method
<?, ?>
private <T,Z> void pdc(final PersistentDataType<T, Z> type) {
}
or what manya said yea
still get that error
?paste your pom again please
that is the wrong group id xD
thanks!
i had that to start with
no
wait
you had your projects group id
no
as a maven variable
bruh
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
this was your first pom.xml
it saied that ona random spigot forum
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
thats it now
is it useful to check if there's more than one player before looping Bukkit.getOnlineplayers?
no
now i get Could not find artifact de.tr7zw:item-nbt-api:pom:2.8.0 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
no
ki
you haven't added the repository needed to even find it
did you read that wiki ?
so im watching this yt spigot dev tips video and he recommends to do whatever this is instead of just passing the plugin name through the method params that uses it. how does this work and why is it better?
wouldn't call it better
only the sysout
yeah why not just do public int doSomething(String pluginName)
meh
that is a perfectly fine way to do it
the functional programming peeps would even prefer that
luckily I am not functional
functional programming peeps?
state?
i'm not a pepe
whats that mean
like that current state of an class instance and its fields
ah
@patent horizon u dutch?
idk, generally the showed example of the yt is not better than passing it to the method parameter. it is a design decision
so if you set the this.pluginName when the plugin starts up like new ExampleManager(pluginName) it'll use that plugin name every time after?
no... american
yeehaw
🤠
Do you know any well-done pluginswhere i can steal database managment from except luckperms
i havent tried databases yet, just local yaml configs
i let my connection open for a week so dont ask me
how do I fix this warning?```
Unboxing of 'player.getPersistentDataContainer().get(nameSpacedKey, PersistentDataType.BYTE)' may produce 'NullPointerException'
use Byte instead of byte, or reqnonnull if you are sure that container has value
so I should put PersistentDataType.Byte?
👀
no
the issue is that the get method may return null if there is no value for the key
I'm sure the key has a value
you say to use Byte but it can be null :/
https://paste.md-5.net/qimamigena.xml i have this now and it works apart from the dependency having a red line underneath (would show img but doesnt let me) @eternal night
.
I believe LibertyBans does a decent job?
does it compile ?
with mvn package
if so, just flame intellij for being trash
Yeah already looking at it
I already mentioned it here, tho, it has very specific design cases. All objects are moslty immutable and you cant really change them in future. Thats.. Easier
Oh
Truw
It uses very weird depency injection
yes it works now thanks @eternal night
👍
That breaks 90% of plugins
uhm
Why is this sending an error?
that is not a task
Hmm, I usually make my data models mutable, however to make it easy to implement proper thread safety I might create humble objects, as much as possible.
neither a runnable nor a Consumer<BukkitTask>
its not weird, just rarely used!!
The problem is in plugins that doesnt relocate their depenencies!
additionally that would not increase the cold value by one either
runTaskTimer is not a task?
no what you are passing as the second parameter is wrong
Do you know how much pain it is when plugin has no src available and liberty is screaming at it
scheduler.runTaskTimer(plugin, () -> {
System.out.println("Example code that hates loggers");
}, 0, 20 * 10);
as an example
but the second parameter is not the action the task does?
what
well
did I miss something
or it's giving an error of other thing
DB management strongly depends on your use case.
But you can always just make the whole DB interaction async and use CompletableFutures + BukkitScheduler to sync back with the main thread 😄
but if i don't do it as lambda it doesn't give an error
I mean, the code i pasted above should work
✨Just report a bug to the developer✨
after I added the initial delay
() this?
just what I posted
For sure, but thread safety and clean api design are bitches
That’s why you wanna separate asynchronous, parallel and concurrent logic with your data model, as much as possible
In many cases (eg if you only need data of online players) you can get away with loading the data into memory when a player joins and lazily unload it when he disconnects.
Some devs are just assholes
then dont use their plugins 
K
Well
I only had to modify 2 plugins
And I pred the changes like normal person
:)
scheduler.runTaskTimer(plugin, () -> {
setCold(1);
}, 0, 20 * 10);```
ok, so this will add 1 to cold every second i guess?
Understandable if you read some of the comments and reviews ppl post on your plugin. A plugin that you provide and maintain in your free time.
Like in Hypixel, how do I change the text above a players head? I tried player.setName() and it didn’t work
They use armorstands don't they
I thought about that
Use nametagedit API maybe
LibertyBans makes world better by being an example of why you always should relocate depenencies 🙂
I can do the armor stands, I was just wondering if there was a built in method of it
are you sure if its done with armorstand
I think most plugins use packets
For thay
I've ran in a lots of issues while trying to do custom name tags with armorstands
Nte and TAB use them
I saw that to, looked super complicated
Otherwise you only have 2 lines to work with
Armorstands only make sense if you want to have multiple lines over a players head. If you just want to change their display name then there are several other ways of achieving that.
I only want 2 lines
So are packets the way to do it then?
I got no clue
Hacking fox in the background
i'm trying to use reflection to handle registering listeners but it throws this exception, and i'm not sure how to fix it
error happens here Set<Class<?>> listeners = new Reflections("dev.millzyg.DiscordInterface.Listeners").getTypesAnnotatedWith(BukkitListener.class); apparently
hey i have question ```public class TagsMenu implements Listener {
@EventHandler
public static void onItemClick (InventoryClickEvent event){
Player p = (Player) event.getWhoClicked();
TagsManager tagsList = new TagsManager(BwCore.getPlugin());
TagsPlayerData tagsPlayerData = new TagsPlayerData(BwCore.getPlugin());
if (event.getCurrentItem().getType() == Material.NAME_TAG){
String prefix = utils.chat(BwCore.getPlugin().getConfig().getString("prefix"));
UUID uuid = p.getUniqueId();
String tagname = event.getCurrentItem().getItemMeta().getLore().get(0);
tagsPlayerData.getConfig().set("Tags."+uuid ,tagname);
tagsPlayerData.saveConfig();
p.closeInventory();
p.sendMessage(prefix +"tag set to "+ tagname );
}
}
}```
uuid:Tagname```
it does nothing
np
cuz i thought about this for a while now lol
how do i get the region name at player
i dont think thats applicable in my case. i have clans which can has a lots of players in it. Then, when should i save clan data? When no online members left? Also, the save operation may be bulk, i wanna avoid unecessary updates if possible. (For example, removing all members from the table and adding them again with new ones)
worldguard?
yes
Connect/disconnect, have a config option for a sync buffer which saves necessary data every x duration, then on certain operations you might wanna query a save.
yes
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().get(new BukkitWorld(location.getWorld())).getApplicableRegions(BlockVector3.at(location.getX(),location.getY(),location.getZ()));
Btw if you haven't checked it out, caffeine is a pretty neat library which has expiring caches as well as soft caches, with removal listeners and what not.
like i wanna see if the region they're standing at is named "pvp"
How can i make an item have an enchant but not say it (just haveing the glint to it)?
enchant it and hide flags
about this it worked but now it saves it like this :
3e8eac9d-c886-47a1-937c-5f0dfdf6114b: "\xa7r\xa7lTEST"```
how u get the hide flags?
use .getRegions() then do for each loop to check for regions name
this javadoc is old
but it should work
I learned that people dont realise how much memory they actually have at their disposal.
If you dont need multi instance support then having all clans in your memory all the time is not a problem.
I would estimate that 1k clans are about 100MB in memory at most.
Yes. Also love it.
@ivory sleet i have question ,
do you think am ready to make a minigame plugin ?
Add the flag to hide enchantments
you're ready anytime
you just need to get the discipline and courage to finish it
how long it'll potentially take ? realisticlyl
You can’t be un-ready, if that helps you decide.
like in hours spent
True tho! And the api will be super simple and single-threaded. Not saying thst its bad, but i always dreamed about multi instance support
depends on the plugin complexity
All you need is a state machine and a rule set to implement. With a bit of work you should be able to write a minigame even when you are not that experienced.
well its time to make a minigame
a practice plugin ?
sumo,thebridge bedwars etc..
something like frost
the more I look at other people's github repos the more depressed I get.
With multiple server instances the whole architecture gets really complicated really fast.
I usually opt for an authoritative Redis or Hazelcast instance in front of my persistence layer (mostly MongoDB)
Hi, How can I create a Handler of two Events ??
I am using Bukkit
@EventHandler
public void onPlayerClickHologram(
PlayerToggleSneakEvent eventSneak,
PlayerInteractEvent eventClick
) {
System.out.println("Double event")
}```
You will need to write/setup several other applications for that.
You cant
EventHandler methods are only allowed to have a single argument T where <T extends Event>
interesting to note that skript has possibility to listen to couple events at the same time afaik (or maybe skript-mirror) but that's wrapping plugin around spigot api.
so I have to create a CustomEvent that contains the other Events?
No
you can do that but that's unnecessary
just create one private method which does the calculation for you, and execute that method in both eventhandlers.
Separate your concerns. What do you need from those events?
@RequiredArgsConstructor
public class SomeListener implements Listener {
private final SomeHandler someHandler;
@EventHandler
public void onSneak(final PlayerToggleSneakEvent event) {
final Player player = event.getPlayer();
this.someHandler.doSomething(player);
}
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
this.someHandler.doSomething(player);
this.someHandler.doSomethingDifferent(player);
}
}
final 🌝
@EventHandler
public void onPlayerSneak(final PlayerSneakEvent event) {
if (!this.doSomething(event.getPlayer()) event.setCancelled(true);
}
@EventHandler
public void onPlayerInteract(final PlayerInteractEvent event) {
if (!this.doSomething(event.getPlayer()) event.setCancelled(true);
}
private boolean doSomething(final Player player) {
return false;
}
when i do condenserWandMeta.addEnchant(Enchantment.ARROW_INFINITE, 1, true); there is no option for .flag after it
do it before
happy?
Yes because this is a void method. And you cant call anything on void
yesh sir
am i the only one who prefers writing this keyword for instance variables, methods?
i dont like it in methods
I always explicitly use this 😄
hey in this same code when i close the menu it sends the message twice ...
i modified the code to match what i have rn
it just makes more clear if the variable derived from instance or it is some sort of local/static variable
Add a small delay prob
that's inventoryclickevent
You can add a cooldown
wdym for two hands
not playerinteractevent
where ?
Idk I'm not an expert
ah uhh
lol
But it probably takes taking and putting back item as 2 event fires
I would honestly try to understand what is happening instead of adding an artificial cd
Cancel the event
ok will try
Should fix it
.setCancelled ?
.setCancelled(true)
ok
I'd put that before GUI closing
Show the code 😄
And share your spigot version while you are at it ^^
1.8.8
Well...
o.o
why do people like 1.8.8 that much?
||PvP||
Use a version that has lost support half a decade ago and expect bugs to happen. Nobody supports/uses 1.8 anymore
only pvp 🙄
last version with an acceptable combat system
fax
mmh me and pvp goes brr so uhh yeah
rip
i expect bugs with anything tbh
so idk
If you like hammering your left mouse button like you are playing cookie clicker then bragging about your cps, then yes.
why have a left mouse button if youre not gonna use it
We use it on new versions, but we have to time our attacks
The thing is that 1.8 bugs will never be fixed. If you find/report a bug in the latest version then there is a good chance it will be gone in a bit.
what does the fox say
ever heard of W tApINg ?
I can just unlock my mouse wheel, set the attack button on it and let it scroll with perfect 20 cps
what the dog doing
(⊙_⊙;)
No plz
all I gotta say is prison wallet
What do you think the tail is being hold by? Right hand occupied-
is this a normal pose? like is this a thing on minecraft or you actually created a new pose for fox ?
that's normal pose
Foxes have a sitting pose
oh ok
Crazy plugin idea, fox hats
Using custom models on fox left hand
@west oxide we don't support 1.8, paper would ban you lol
wait what i was joking pls no
We don't ban
paper = player . owner ?
Another server software
Spigot fork
a.k.a paperspigot (nowadays just papermc)
