#help-development
1 messages · Page 1462 of 1
@summer scroll is this fine?
public final class EZAfkPlugin extends JavaPlugin {
public static EZAfkManager AFKManager = new EZAfkManager();
public static Team afkTeam;
public static Plugin instance;
public static EZAfkManager getAFKManager() {
return AFKManager;
}
@Override
public void onEnable() {
// Plugin startup logic
AFKManager.initialize();
instance = (Plugin) this;
getCommand("afk").setExecutor(new EZAfkCommand());
getServer().getPluginManager().registerEvents(new PlayerDamageListener(), this);
getServer().getPluginManager().registerEvents(new PlayerMoveListener(), this);
afkTeam = AFKManager.getTeam();
}
ignore afkTeam= AFKManager.getTeam();
forgot to remove it
oh, you already use singleton, so let's use that i guess.
first of all make the variable camelCase.
AFKManager -> afkManager
there
on another class
EZAfkPlugin.instance.getAfkManager().getTeam()
that's how you get the team
also what is singleton?
EZAfkPlugin.instsance.getAfkMnager().getTeam() doesn't work
'cannot resolve method getAfkManager() in Plugin'
public final class EZAfkPlugin extends JavaPlugin {
public static EZAfkManager afkManager = new EZAfkManager();
public static Team afkTeam;
public static Plugin instance;
public static EZAfkManager getAfkManager() {
return afkManager;
}
@Override
public void onEnable() {
// Plugin startup logic
afkManager.initialize();
instance = (Plugin) this;
getCommand("afk").setExecutor(new EZAfkCommand());
getServer().getPluginManager().registerEvents(new PlayerDamageListener(), this);
getServer().getPluginManager().registerEvents(new PlayerMoveListener(), this);
afkTeam = afkManager.getTeam();
}
take static off the method
make it non static
it won't
i've made getAfkManager() non-static and it still says the same thing
if you are using static access you shoudl not be using instance
i meant getAfkManager() sry
public static EZAfkManager afkManager = new EZAfkManager();
``` and this one too.
if you use instance you should be grabbing that via a static getter(), then accessing non static methods
still says the time
i am doing EZAfkPlugin.instance.getAfkManager().getTeam();
getAfkManager() was static, it gave me an error saying it can't resolve the method
i tried making it non-statica ndi t says the same
okay
i think you're doing the singleton wrong
private static EZAfkPlugin instance;
@Override
public void onEnable(){
instance = this;
}
public static EZAfkPlugin getInstance(){
return instance;
}
Oh
EZAfkPlugin.getInstance().getAfkManager().getTeam()
no errors anymore, gonna try it out now
@summer scroll
[15:17:50 ERROR]: Could not pass event PlayerMoveEvent to EzAFK v1.0-SNAPSHOT
java.lang.NullPointerException: null
at me.notprankster.ezafkplugin.events.PlayerMoveListener.onPlayerMove(PlayerMoveListener.java:21) ~[?:?]
this is line 21
if (afkTeam.hasEntry(p.getName())) {
show more code
package me.notprankster.ezafkplugin.events;
import me.notprankster.ezafkplugin.EZAfkPlugin;
import me.notprankster.ezafkplugin.commands.EZAfkCommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scoreboard.Team;
public class PlayerMoveListener implements Listener {
EZAfkCommand afkCommand = new EZAfkCommand();
Team afkTeam = EZAfkPlugin.afkTeam;
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
if (afkTeam.hasEntry(p.getName())) {
afkTeam.removeEntry(p.getName());
p.sendMessage(ChatColor.GRAY + "You are no longer AFK.");
}
}
}
you're still doing the same thing.
oh wait
oh
i am actually very sorry
i forgot to change the variable
i'm being stupid
did it, starting now
package me.notprankster.ezafkplugin.events;
import me.notprankster.ezafkplugin.EZAfkPlugin;
import me.notprankster.ezafkplugin.commands.EZAfkCommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scoreboard.Team;
public class PlayerMoveListener implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Team afkTeam = EZAfkPlugin.getInstance().getAfkManager().getTeam();
Player p = event.getPlayer();
if (afkTeam.hasEntry(p.getName())) {
afkTeam.removeEntry(p.getName());
p.sendMessage(ChatColor.GRAY + "You are no longer AFK.");
}
}
}
like this, right?
yes, exactly.
works perfectly now, thank you
np
I don't think listening to movement is the most efficient way of doing things but oh well
it isn't
it's far more efficient to store the location of players, put it in a task and then compare the locations within a repeating task and put them out of afk if the location changed between two checks
then put the check at 1s or something
how do I set set a player's max health
like how many hearts they can have
since player.setmaxhealth is deprecated
did you try reading the javadoc
declaration: package: org.bukkit.entity, interface: Damageable
aren't you supposed to use an attribute now or does that not apply to max health
that's right
is this not how you do it?
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(new AttributeModifier("MaxHealthModifier", maxhealth, AttributeModifier.Operation.ADD_NUMBER));
yeah thats exactly what the javadocs says
He's trying to show them what is the alternatives of the setMaxHealth.
but I get errors? :/
I'm very new with database, can someone give me some advice? Here's my current database code https://github.com/aglerr/TheOnly-MobCoins/blob/master/src/main/java/me/aglerr/mobcoins/database/SQLDatabase.java
#setBaseValue(maxHealth)
Bukkit.getPlayerByName()
wtf is that function
I don't think that exists 
there's Bukkit.getPlayer(String)
is doing ```java
Bukkit.getPluginManager().addPermission('myplugin.something')
mandatory?
ok ty
so putting them in my plugin.yml is enough then
and another question, is using permission: for each command (like so)
commands:
mycommand:
description: Returns a helpful message with details about each command.
permission: myplugin.mycommand
myothercommand:
description: Returns a helpful message with details about each command.
permission: myplugin.myothercommand
or with an if in the code
if (!player.hasPermission('myplugin.mycommand')) {
player.sendmessage('you aint got perms for this bud')
}
better?
include it in plugin.yml
including it in plugin yml sets it as the required permission of the PluginCommand object
which allows the /help list to make informed decisions on whom to show the command to, and so on
it allows programmatic access to the information, which is better
ok ty
checking the permission in the command is also redundant unless you want to do something fancy with no-perms failure
as the server will check whether a commandsender has the required permission before invoking your command executor
and if not, it will print the no-permission message
i don't remember if you can customize that in plugin.yml
ok thanks!
will the server also check before doing the tabcompleter?
i don't know actually
it would make sense for it to do that
but bukkit and making sense don't always go hand in hand
My bad that's what I meant
Nope, tab complete is independent from the actual command
the permission here is just permission to execute the command
If you want permission to be enforced for tab complete, you'd have to use the line of code you suggested above in the onTabComplete method
that
ok
I've never actually bothered with the plugin.yml permission attribute for each command
seems like an unnecessary form of double data entry
or you could ditch plugin.yml all-together and add your commands to the command map yourself
Why? You don’t need to put it anywhere aside from plugin.yml
as long as you register them somehow be it through plugin.yml or at runtime, it's fine
but again, if you don't register a permission to a command, /help lists and shit will display your commands to people who should not have rights to use them, and that can lead to quite a bit of butthurt among admins
plugin.yml would generally be preferred over registering them at runtime, as it sort of acts as built-in documentation for all of your commands and permissions
can you set different permissions for subcommands
as in you need myplugin.mycommand.* to do everything with /mycommand
but you only need myplugin.mycommand.something to do /mycommand something
not through the plugin.yml no
ah
You can only give it one permissions for the main command name right?
yeah, plugin.yml doesn't acknowledge the concept of subcommands
^
but i cant just set myplugin.mycommand.* for it
In the terms of material of an itemstack would AddTypeOfInterest or AddMaterialOfInterest which one of the two is beter
because im thinking Type is unambiguous
Usually why I would just add permissions in code
and you would get yelled at by admins for not registering them properly
f.e worldedit not registering its permissions to its commands and shitting up every server's /help list is a permanent source of ass pain for everyone
not providing programmatic access for other plugins and the server to see which commands require which permissions is bad practice
it "works" but it's not good
Well...
if you absolutely don't want to use the plugin.yml, register the permission at runtime in your source
there technically is a way to 'grab' all the permissions
only if the permission is declared somewhere
it's not great though
that is, if you have registered a command to have that permission
or done new Permission() and registered the permission itself
If they've used plugin.yml to register commands
then its easy to find them
the commands yes
this.getCommand()
but if you don't associate the fucking permissions with the commands
the server can't tell what the permission is
do you get my drift
the server can't tell if you're doing .hasPermission(string) somewhere in your code
Never bothered to look into it too much though
for programmatic access, you must either register a permission, or set your command to use a permission
No, but a plugin can
I meant a plugin could be designed to find such permissions
it still can't
like luckperms
that is a permissions plugin, it can check calls to it yes
and why is that?
but you shouldn't rely on that
the 2 ways to do it are to
1 look at the bytecode of the jar, looking for calls to Permissible::hasPermission(String)
2 be the permission plugin and record all of the checks made to your permissible impl
nobody in their right mind would do 1
and you shouldn't rely on 2
and you would know this how?
and even if someone does that
you shouldn't rely on it
because it's not part of the API
don't rely on the permission implementation, rely on the API
but 2 gives a much more accurate tree of permissions
it gives just as accurate of a tree as registering them properly
than just reading the base permissions for each main command
plugin.yml cannot register sub command permissions...
Kind of does?
can't really register multiple permissions if they're not supported...
you can register as many permissions as you want
if the API doesn't support them, people will look elsewhere
new Permission().register()
or you can declare them in your plugin.yml
anyways, i'm off, got stuff to do
bottom line is: don't be a retard, register your perms, use the api like it's intended, don't rely on some arbitrary impl
I don't know what I'm doing wrong. Can one of you nice people help me figure this out? When I reload the plugin it doesn't kill me.
No I'm trying to figure out how to make methods
myMethod() string of code that kills me
So if I type myMethod(); anywhere in the code it kills me
an arbitrary implementation if favoured if its less complex or the API doesn't support something the developer wants. The permission class just seems to be attachable to permissibles not the commands themselves... this.getCommand() only has the option to set one command permission
Is there a way in java to override methods in objects that are created using the builder pattern?
Lets say I have a Car class with a CarBuilder inside of it (public static). the .build() method on the builder instantiates a Car from a private constructor. Now I would need to override some methods in the Car class. I don't want to pass any code as argument (bifunctions and the like). I personally think it is not possible while still adhering to the OOP style but if anyone has an idea: shoot
can i add several permissions to a command and require any of them in my plugin.yml?
nope
command class seems to only allow one permissions to be registered with it
:c
make the method
myMethod(Player player) {
player.setHealth(0);
}
Listener classes are for events however, there is no need to have static methods in them. If this is for testing purposes, make a TestUtils class for it.
If you cannot get a Player object, modify the code like this:
myMethod() {
Player player = Bukkit.getPlayer(<insert username>);
player.setHealth(0);
}
so for every logic implementation I just do a .hasPermission
When you send a plug-in message from the bungeecord to the spigot and vice versa, is there a chance that message could be leaked or reed from another server/player?
so i just set none and do it on the code
yep
that seems like a question for MD_5 since he built bungee
do it in onCommand
^
some people in code love to do a long if or switch statement
checking for args
or even command name 🤷♂️
Should I ping him...
haha, you can if you want to
dont you have to do that if you have several commands in a class
ooooorrrrrrr, you could use the MmCommands command framework 😉
but it doesnt support multiple perm nodes at this time so doesnt really solve the issue
not saying you should do that
I personally don't have multiple commands in 1 class, its horribly unreadable and breaks the Single responsibility principle anyway
one command per class
ok
makes it a lot easier to find
example of how I do my perm checking on commands
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only a player can do this.");
return true;
}
Player player = (Player) sender;
if (!player.hasPermission("enchantgui.use")) {
player.sendMessage("§4§lERROR§8 » §7Insufficient permission.");
return true;
}
String world = player.getWorld().getName();
if ((getMainConfig().isBlacklist() && getMainConfig().getWorlds().contains(world)) ||
(!getMainConfig().isBlacklist() && !getMainConfig().getWorlds().contains(world))) {
player.sendMessage("§4§lERROR§8 » §7EnchantGui is disabled in this world.");
return true;
}
new VirtualEnchantTable(player);
return true;
I am aware color codes are not done properly. its a very old plugin.
what is the difference between return true and false?
in the onCommand method?
true means: Command executed successfully. false means Command failed. If false is returned, the usage parameter from the plugin.yml will be printed to the user
I always return true because I handle displaying the usage myself
correctly list your commands in your plugin.yml and have one class per command and you don;t need to do any permission checks.
i was watching the bedwars1058 author working of the plugin and he uses only return true
in his pl.yml not have commands
why not?
That is because they handle displaying the correct info themselves. You only return false if you want bukkit to display the usage
they are all in the java classes
plugin.yml has to register all commands. There is no way you can register them through code
like: cmdgui.class and is /bw gui command
the /bw command then has to be in the plugin.yml
are they using like precommand event thing?
the plugin.yml does not allow for fine permission checks however. So for plugins with an advanced command system, doing permission checks manually is the way to go
each class per subcommand is gud
probabbly yes
- it allows you to display errors that fit your plugin style instead of the default errors
yep, have the bw command in the plugin.yml and a permission to use it, then you manually check child command permissions.
for example: in pl.yml i set bw and a perm like bw.player
and bw.admin for admin commands?
probabbly i don't publish the original plugin because it's privaye, but i can create a little versions for all users
i have that too, way more simpler. https://github.com/aglerr/TheOnly-MobCoins/tree/master/src/main/java/me/aglerr/mobcoins/commands
You can also use a command framework
mine is an API xD its not an implementation
full explanation on their wiki
start here
My tnt duper breaks whenever I leave the chunks any way to fix it?
wrong chat
and if it is a vanilla duper, better just look it up on youtube
.
maybe dumb question but... is String#contains case-sensitive? if yes, how to use it ignoring the case?
Hey look at the documentation?
messages are send unencrypted and there is no authentication on the channels, so yes a message could be intercepted
not really giving me the answer tho
Then, how
I do think it is not case sense tive
Why don't you test it?
contains IS case sensitive. use a toLowerCase first
alright. thanks bud
what do you mean?
did i ever say i hate mysql? if not:
i hate mysql
How can you intercept the message...
Yes that is true... But I'm talking about notnplugins
in fact you could probably even read the channel
But the player....
Is there a way to cancel a modded player from receiving the message then?
Can't you use e.setCancelled
no, thats server side
I want to cancel a message from a spigot server reaching the player thru a bungeecord
Can't the bungeecord cancel the packet.
pretty darn sure there is an event for that but dont quote me on it
You are going to have to give more detail here. More than just a packet
the idea is simple...
When a player joins the bungeecord, the bungeecord sends a message to the spigot server authenticating the user and then the spigot sends back to bungeecord to authenticate the user, like a NoProxyJoin plugin, but the thing that I'm scared is about this key getting stolen.
you want a specific player to not receive a message, correct?
also
blocking modded users from joining is a very bad idea
most everyone uses at least some performance enhancing mods
such as sodium or optifine
my idea is not that at ALL
well
you are conveing your idea very badly then
because no one understand what you want
I don't want them to steal the code that is on the plugin message.
I've even encrypted it etc, etc, etc.
the idea is to prevent the message from being stolen... that's it
Yeah, we have no idea what packet you want to block
why setDisplayName on a player don't work ? is it only reserv for mob ?
prevent what message
it does work
i setDisplayName("something") but nothing change
it's the plugin message packet
from the spigot to the bungeecord
I want to prevent it from being reed by modded clients
can you send the code?
?paste
settings display names is way harder then that....... well if you're going for prefixes that is
are there any errors?
i know i just wanna know why he say it work
nop
setDIsplayName never worked for me neither so..
Then the issue is detecting if the player is modded the first place. This guaranteeable with Forge, but with Fabric it isn't
...
[17:35:09 WARN]: The exception was: java.net.BindException: Address already in use: bind
[17:35:09 WARN]: Perhaps a server is already running on that port?
[17:35:09 INFO]: Stopping server
[17:35:09 INFO]: Saving players```
READ
^
"Failed to bind port"
jadss be more gentle
sorry I got PISSED.
you shouldnt be pissed cause of the code you used to write that was horrible lol
we don't talk about that..
how to fix it i closed all terminals where i ran the test server
Hey there, quick question. What class should I be looking at for spawning particles client side only? I couldn't find any class with 'Particle' and 'Packet' in it's name in the net.minecraft.server package in Spigot
tho not pissed about that, AT ALL.
sorry for being a idiot
task manager (windows)
or activity moniter (mac)
ok
or by a command on linux
Check if the Java task is still running
Thinking of it, A particle is an Entity so I should be looking at spawning an Entity I'm guessing 🤔
what do you mean clientside?
I need to spawn a particle only visible to one person, i.e the client
do you actually use allman...
i despise you
Yeah thats what I was looking for, but I couldnt find a class named anything with particle and packet in the same name in the decompiled Spigot
...
or is that correct?
^
complicated....
PacketPlayOutWorldParticles
O.o thanks
Odd that that didnt show up when I searched in jdgui
do you actually decompile the server jar 👀
yeah
pretty sure IDE's have it built in
Well uh, dont you need the nms anyways if you are working with packets?
or the spigot artifact
nah
i don't understand i have teams link all to the same scorboard, when i try to set prefix and add a player to a team nothing change on his display name above head ? someone know why ?
I've written some utils for it to make it pretty easy 😄
someone can give me the name of this colors:
Purple,
Gold,
Magenta,
Black,
Cactus Green (Dark).
for a bedwars plugin
now if the version changes and the packet format changes
what you gonna do
I just update the plugin 🙂
for now i have:
RED,
BLUE,
GREEN,
YELLOW,
AQUA,
WHITE,
PINK,
GRAY,
No, im talking about the actual packet itself
but it is less updating than depending directly on the specific dependency
Since then I'd have to update every release due to the versioned packaging
Now it's just whenever mojang changes something I use
reflection is slow tho
depends
invocations are slow I should say
I do most things statically, so it is only done once when the classloader first loads the class
pls send
Just saying, working with the actual code is going to significantly faster compared to actual method calls even when you are caching the Method. It is bad for packets because you are going to have a bigger delay before sending the actual packet
Yes you can cache reflective objects but you cant cache Method#invoke or Constructor#newInstance (not talking about the result) and yes its optimized by JIT but even so a hunk of abstraction layers are faster
Yup true, I try my best with most things
but I'm not out seeking every last milisecond here 😄
Reflection should be only used to do impossible things.
🥲
bruh
Because I support 1.8 lmao
not really?
right, 100% slower, it will take twice the time. In terms of miliseconds, it's still not noticeable
I use reflection quite a lot, even outside Minecraft. E.g last week I build a class validator for when working with json deserialization, reflection is necessary then
that entirely depends on context and how much you use it logicaldark
it scales up based on the task
Not using reflection because it is 'slower' is a bad reason
If you're using reflection to iterate through a list of n elements then ofc it will scale. You're doing it wrong
Not at all
Yeah idk what you are saying lmao. Using reflection for hacks are not good at all
It's slower too
and less readable
Attempting to optimize performance in terms of speed isn't bad if it isn't diminishing that is
The point is reflection is still a useful tool that you shouldn't just throw away because hurr durr it takes a little bit longer
We never said to throw away???
since when did we ever mention that
Reflection isn't always used for a hack though. Take e.g Google's Gson, it would not be possible without reflection
You use reflection when you have exhausted other faster methods
but in this case, it is
right
Sure it's a bit slower, but it has its purposes. Reflection is useful when there are no other routes to use
^
But there are other routes...
Idk what your point was really
We literally already stated that in the beginning to only use reflection for doing impossible stuff
Do tell how I can spawn a particle client side without reflection or depending on the non-api dependency 😄
this
Is calling a save method that open and close connection to database for every object is efficient? https://paste.helpch.at/uyugamijic.js
this?
You can spawn it without reflection using the spigot artifact
wdym
?
Exactly, then I have to depend on an artifact which changes every version due to versioned packaging
You wanna add colour to the players name?
Server side yes. But not per client spawning.
yep
easy
nice to know but how ?
Sure, but I'd rather use versioned packaging cause I will just say in most cases you can just copy and paste code back and forth unless you reach one of those things where you have to create your own classes for it to work and shit. But reflection is even less helpful if you were to hit that roadblock anyways...
i already use it
help
if you read messages...
Correct, I could. It's what I did in the past. But I stopped doing that since I really dont feel like doing that work every update, I'd much rather do it every once in a while when Mojang changes things, which isn't all that often
dude make a fu*** one message
you would be dealing with a fuckmess if they do change things
anyone
Fair point, but I like that puzzle
at that point, you mine as well use NMS
he give me this link
I see no point otherwise
there are other people who also need help
I can usually figure things out by looking at the server source 😄
you sound entitled
i will come back ask support when child will go to the bed
so you change the team prefix and then add a player
but his name doesn't have the prefix
already done
above his head
and it don't work
i dont know
Zuzzymc give me this link discord
and he said go ask in help development
:0
If you're developing a plugin
you ask for help in here
if you're not a dev, you ask in help-server
for help with using a plugin
Is calling a save method that open and close connection to database for every object is efficient? https://paste.helpch.at/uyugamijic.js
every player has a player data.
i call it onDisable.
so it can't be async i guess?
it could be
but it's onDisable no really need to here
unless he want to do multiple things on it
If you want to get efficient, you could queue updates to the database when a player does something that requires a change in the database
after x number of minutes, commit the update
if you have 100000000000 players it's cleary not efficient it's better to create a connection and use it to save all players data then close it than open it for each player
that way you don't have to do a massive loop and save when the plugin gets disabled
yeah imma do that instead.
oh yeah ofc
I would say keep it open during plugin use and then close it when its disabled
tips made it async if later you wanna implement some kind of auto-save
I'd say just save their data as soon at it arrives
but if a player performs an action many times
you're hammering the sql server
is this good enough? https://paste.md-5.net/zolefikagu.cs
not a good idea it's better to load localy the data and after process send it back
^
Oh he's saving like that.
SQL request take a lot of time
I'm just saving data every time my minigame's onFinish() method is ran & only saves the players that took part of this game
Use HikaryCP
or whatever it's called
for your use: better
Depends
I hate this
what is that mean?
it's good
Saving on disable is usually not great lol
From my tests, connection time was about 1s, while sending the data took like 50ms
What happens when your server crashes? all their data is gone
50ms is very long for a program
his problem
here he only want to save data on unLoad that's all
i'll take some advice too
.
It's 1 minecraft tick bruh
if it's not good and can cause issues, i'd love to know
yep this is very long
in the worse case they loose a few minutes
But still that 1s connect time caused some dupes on my plugin :p
depending on the queue delay
???
i always use async if it's not onDisable
As I was syncing items
they don't loose 'all' their data
It only saves every stop
i also save every player quit the server
oh okay
this
If the data comes in at a relatively slow rate I'd say just save it on the spot
You sort of have a 'Bean' object to hold this information
ah, like create another hashmap
that's the point of the queue...
and when player transfer balance
to another player, put them on hashmap and the amount of coins
that works?
no because in my case you don't do some queue shit beforehand 🤔
no, you just want to hammer the sql server
despite those sort of requests taking time
I said if the data comes in a t a relatively slow rate
e.x: at the end of minigames
yeah if it comes in a slot rate, that's not a problem, it doesn't do so well for when it comes in quickly
yeah so it just comes down to how he's structured the project
Regardless of all that, use HikariCP
Ideally you would allow x number of sql operations per second, and do it on another thread to stop the server being overwhelmed with requests
the idea of the Bean object is that if a player is just changing 1 variable constantly, it makes no sense to also constantly update it in the database
wait for the variable to settle or when x minutes have passed
Slaps SQL server You can fit so many statements in here
hey
I already have my account verified on spigot
but i cant verified me in my discord acc on #verification
I believe the name must match
Hell, and how do I change my name to spigot?
donate to change
Hi ! So i'm trying to set a prefix to player (player tag above head) that join a team but when they join the team with prefix of set nothing change:
Here the declaration of the the team :
private void build() {
this.team.setTeam(scoreboard.registerNewTeam(getTeamEnum().getName()));
this.team.getTeam().setAllowFriendlyFire(GameSettings.FRIENDLY_FIRE);
this.team.getTeam().setColor(this.getChatColor());
this.team.getTeam().setPrefix(this.getPrefix());
this.team.getTeam().setSuffix(this.getSuffix());
this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.COLLISION_RULE, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.DEATH_MESSAGE_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.ALWAYS);
}
and here the method when i add a player to a team :
public void addPlayer(UUID uuid) {
Player p = Bukkit.getPlayer(uuid);
if (p != null && !hasPlayer(uuid)) {
getPlayerList().add(uuid);
this.team.getTeam().addEntry(uuid.toString());
p.setPlayerListName(getPrefix() + p.getName() + getSuffix());
p.setScoreboard(scoreboard);
playerStatusList.put(p.getUniqueId(), PlayerStatus.ALIVE);
}
}```
just adding that scoreboard is a scoreboard share for all teams color
And of course i check if the prefix value is not empty or null and i confirm there is prefix value
thx 🙂
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();```
i remove it from the method addPlayer but i can add it in it
i made some test with a addPlayer to the score board it change nothing
Is there an event to get any "/command" a player is running, like there is for the AsyncPlayerChatEvent?
cheers
i add it to the method and nothing change
public void addPlayer(UUID uuid) {
Player p = Bukkit.getPlayer(uuid);
if (p != null && !hasPlayer(uuid)) {
getPlayerList().add(uuid);
this.team.getTeam().addEntry(uuid.toString());
p.setPlayerListName(getPrefix() + p.getName() + getSuffix());
p.setScoreboard(scoreboard);
playerStatusList.put(p.getUniqueId(), PlayerStatus.ALIVE);
}
}
this problem begin to blow my mind
public void setupTeams() {
teamList.add(new Team(TeamsEnum.RED, this.scoreboard));
teamList.add(new Team(TeamsEnum.BLUE, this.scoreboard));
teamList.add(new Team(TeamsEnum.GREEN, this.scoreboard));
teamList.add(new Team(TeamsEnum.YELLOW, this.scoreboard));
teamList.add(new Team(TeamsEnum.SPECTATOR, this.scoreboard));
teamList.add(new Team(TeamsEnum.MINOS, this.scoreboard));
}```
btw you can do
for (TeamsEnum teamsEnum : TeamsEnum.values)
teamList.add(new Team(teamsEnum), this.scoreboard);
if you wanted to make that cleaner.
someone know how to set a lobby-fly? the fly for only the world where i have set the bw-lobby
well i agree but that don't change the problem of prefix
without blacklisting a world
onPlayerJoin -> if(world.getName.equalsIgnoredCase("youWorld') player.setFly(true);
add a check
where can i put this so ?
i need to add it on a join team "event"
and even if i move it i don't understand why it don't work
Why the tps is so low I mean like eating takes so long
And mobs don't tick fast
Any fix?
not a devlopement problem go to #help-server
Hello! How to get net.minecraft.server.* in project maven repository that compatible with what I get spigot-api?
usually you want to depend on spigot instead of spigot-api
Orr ok
note tho that you will need to run build tools for the specific version of the api at least once before actually compiling the project
spigot cannot distribute the spigot maven dependency which includes net.minecraft.server on its own, so this is sadly the only way to install it onto your computer
Ahh, so I need to use a library instead of using repository in pom.xml?
well no, just the reference itself is fine
maven will check your local maven repository (which build tools installs it into)
Ok, thank you!
I have a runnable bukkit in a wall class. And I would like to get my wall object (this) in this runnable. But here this will refer to the runnable and not to the wall. Is there any way to get my wall without storing it somewhere?
public void run() {
....
WallManager.getInstance().destroyWall(this (##THE WALL##) );
....
}
}.runTaskTimer(ac, 0L, 5L);```
What is your class name ?
the one you want to reference using this
Wall
it's not a methode from class wall. It's a method from the class WallManager.
In class Wall, I want to use a WallManager methode:
public void destroyWall(Wall wall) {}
but Wall.this should work 🙂
thx
Yeah was more of an example xD
could someone point me in a better direction to do this? https://paste.md-5.net/wijuxoyihe.cs
its X locations each location has 4 values and they might change depending on the other 3 values, theres a constant cooldown on timeLeft, unless the other 3 values fulfill a certain condition, i have no idea how to improve this
getSpawned should really be isSpawned
hm yea
still i feel like this is really bad for the server
like a lot of calls, conditions, a constant cooldown
Is there a way to use an if statement for an event? The code I have now is ```java
@EventHandler
public void onPlayerMessage(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
data.addChat(player.getName(), player.getUniqueId(), event.getMessage());
}
@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
data.addChat(player.getName(), player.getUniqueId(), event.getMessage());
}
are your locations stored in a List or map?
'1':
world: world
X: -329.95103133350807
Y: 106.0
Z: 134.54906892122315
spawned: false
unlocked: false
clicked: false
timeleft: 0```
up to 28
wait i forgot to add the return on the conditions, that should help too
This is your code cleaned up https://paste.md-5.net/coqehawulu.bash
rename getSpawned to isSpawned and getUnlocked to isUnlocked and its much more readable.
ok
How often are you running that? Once per minute?
Wait your getting from the config once a second without caching?
wdym
Are you getting stuff from the config
yea
Doesn;t matter, config is just a map access
okay
this bot is so annoying lol
i will add a try and catch later tho
rn i know exactly what im working with so i just want to make it work
yep, get it to work first is always a good plan 🙂
anyone ?
What is your problem?
do you see the message or did i need to repost ?
Ok, its a simple task with teams
what do you mean ?
adding a prefix to the players name over their head
yep ?
show me some code.
all in the first message
addEntry don't ass the player to the team ?
You havn't set the prefix on the team
Could anyone tell me how persistent data holder works internally?
Does it load the data from a file each time the holder is loaded into the server and store it to the file every time its unloaded?
i do inside the build method : ```java
private void build() {
this.team.setTeam(scoreboard.registerNewTeam(getTeamEnum().getName()));
this.team.getTeam().setAllowFriendlyFire(GameSettings.FRIENDLY_FIRE);
this.team.getTeam().setColor(this.getChatColor());
this.team.getTeam().setPrefix(this.getPrefix());
this.team.getTeam().setSuffix(this.getSuffix());
this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.COLLISION_RULE, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.DEATH_MESSAGE_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.ALWAYS);
}```
ah
Without Paper's player.getClientBrandName(), is there any way to detect if a player/client is using LabyMod/OptiFine or something else?
Then you are either not setting the scoreboard correctly to the player or you are funking up the storing of yoru team
are you always using the same scoreboard?
scoreboard = scoreboardManager.getMainScoreboard();
yep
also Teams are persistent, so if you already created the team you code will now be erroring out trying to create teh team a second time.
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();```
Unrelated to your issue, but you could simplify that code a lot. the 'this.' don't seem to be necessairy, and you should cache the 'get team' to a variable instead of calling it 7 times.
thats NewScoreboard
yep
yep someone already tell me and i make some modif
are you creating the scoreboard Once for all teams, or a new one each time?
only once
scoreboard is always the same during the game
and init onLoad
what is the url to the 1.16.5 maven repository
Then Simplify your code till it works. I gave you code that you've seen work
@acoustic tokenSpigot? It's the same as always, https://hub.spigotmc.org/nexus/content/repositories/snapshots/
i add his method on addPlayer i do this now :
public void addPlayer(UUID uuid) {
Player p = Bukkit.getPlayer(uuid);
if (p != null && !hasPlayer(uuid)) {
getPlayerList().add(uuid);
this.team.getTeam().addEntry(uuid.toString());
p.setPlayerListName(getPrefix() + p.getName() + getSuffix());
setScoreboardForPlayers();
playerStatusList.put(p.getUniqueId(), PlayerStatus.ALIVE);
}
}
private void setScoreboardForPlayers() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.setScoreboard(scoreboard);
}
}```
but still don't work
are you adding the player to the team by name?
uuid
but if a player join during the setup of team i need to add him in the scoreboard
add the player by name not uuid. It works here with name
k
HOOOOOOOOO
IT WORK
it was this
add with uuid don't work
maybe need an update
thanks a lot guys
@wraith apex
if the API doesn't support them, people will look elsewhere
The API supports what you want to do. You just don't want to do it
register is not actually a method
yes, permissions are registered upon instantiation
an arbitrary implementation is favoured if its less complex or the API doesn't support something the developer wants.
you should keep the end user in mind. currently you are debating the difference of an one-line addition to your code, or two at most to your plugin.yml, both of which can easily be abstracted away by using a proper and established command framework which does the work for you; not having to write this one line of code is not worth breaking compatibility with the api and relying on an arbitrary permission plugin. not every end user even uses a permission plugin to begin with, and many people still do not use luckperms. In addition to this, luckperms doesn't do what you believe it to do, and you still need to assign a permission to your command for inter-plugin compatibility to work properly
this.getCommand() only has the option to set one command permission
And one command permission is perfectly sufficient. Plugins such as /help list providers will use this singular permission to determine whether players have the access to this command. If you have subcommands which have their own permissions, you should set them as a parent to the root command permission so it is inherited. You can do this either via plugin.yml or programmatically using Permission::addParent. This is the case whether you use luckperms or not, and doing so is good practice
@visual tide
can i add several permissions to a command and require any of them in my plugin.yml?
yes you can; do what I said above
bottom line remains as: don't be a retard, follow the convention, use the api
Lol nice one
?paste
should this work as lock method for a chest/barrel just every block that can be locked? btw the MagmaBuildNetwork.playersWantingLock is a list with players who executed the command.
https://paste.md-5.net/agepavehoj.cs
public static variable 😐
uh
don't expose state directly
make a getter method for it and make the field itself private
making it static is unnecessary and is presently only the case because you don't know how to access an instance field
yea dont want to call the method every time..
you can not want to do it all you want
but you still should
i don't want to stop at the red lights either
don't call getState multiple times
each getState clones the entire block state
which can be catastrophically expensive
call it once and store the blockstate in a variable for the rest of the method's execution
or use paper(lib) and call getState(false) to avoid the clone in the first place
don't use a list of players, use a set of players
you do not need nor do you want duplicate elements
don't create a new namespaced key each time, create it once and store it in a field for the rest of the session
oher than that, it looks fine
well. the if conditions are pretty spaghetti
probably want to clean those up
but if i want to call getState once i have to declare it one time at the top of the code but that causes every time a player interacts it would check the state of the block seems unnecassary
uhu yea bit complecated
BlockState state = block.getState();
you are already doing this
just move it up
if (!(event.getClickedBlock().getState() instanceof TileState))
and use it here
well i have to check if the block even has a state
yes
you can check whether the variable has something in it
just move the variable declaration up
and use the variable in your code
rather than repeating the method
if (!(state instanceof TileState))
@wraith rapids
- No it doesn't that's why I will use reflection.
- This is not mentioned in the java doc, even if they are registered, they're not attached to anything, you have to store these somewhere.
- I am the end user, even if I were to release the plugin, the end user shouldn't need to poke around in the yml and probably never will because that is kept inside the .jar I never gave an exact diagnosis on what luckperms actually does behind the scenes I was just speculating on what it does. The fact is, it does produce an accurate permission tree. I'm debating the unnecessary double entry of data. Why would I register my command once in the yml and then have to get it and attach an executor to it? I should just be able to add them and remove them when a plugin is enabled and disabled. I'm not relying on any permissions plugin. If people don't use a permissions plugin, that's not my problem.
- In your opinion? I'm not creating a command for every variant or way that it can be executed just because I want to add a permission in the traditional sense. Permissions should be suitably documented by the plugin developer not just left in the yml for the end user to find.
bottom line is: I know what I'm talking about, and I'll break API conventions if it makes plugin development more efficient. Just provide good documentation when you do so if you plan to hand it off to an end user.
if you are registering your command and a permission for that command then that is fine
and yes, you may be the end user in this particular case
but do not fucking teach newbies bad habits
you can shit up your apartment all you want, but don't teach the child to shit in his bed
Why would I register my command once in the yml and then have to get it and attach an executor to it? I should just be able to add them and remove them when a plugin is enabled and disabled.
this is what basically all command frameworks do yes
I'm not creating a command for every variant or way that it can be executed just because I want to add a permission in the traditional sense
and i'm not telling you to do that
so like this on the first lines?
Block block = event.getClickedBlock();
if (!(event.getClickedBlock().getState() instanceof TileState)) {
TileState state = (TileState) block.getState();
}
maybe reuse block but yea
no
call block.getState() once
Block block = event.getClickedBlock();
if (!(event.getClickedBlock().getState() instanceof TileState)) {
TileState state = (TileState) block.getState();
}
vs
Block block = event.getClickedBlock();
BlockState blockstate = block.getState();
if (!(blockstate instanceof TileState)) {
TileState state = (TileState) blockstate;
}
owh okay
Permissions should be suitably documented by the plugin developer not just left in the yml for the end user to find.
i'm not advocating for documentation, I'm advocating for programmatic access, of which the plugin.yml is the default gateway
if you have an alternative method that does it properly, then use it, but what you've been saying so far is that you do not use plugin.yml and have not mentioned a command framework, which is misleading to the beginners
Breaking api conventions if it makes plugin development more efficient lol
the commandmap is exposed in paper api :fingerguns:
Yeah spigot argues for that it’s an improper api design
But Idk tbf
I mean consider how many plugins that actually reflectively grab the cmdmap
On top of that it also has an interface like wat
improper api is better than nonexistent api
at least there's a standard of some kind, even if it is ass backwards
Yeah
I'm pretty sure doing this is not possible, I've searched on google a bit and some people have said its not possible but I'm going to ask here just in case someone knows a workaround.
Is it possible to have both "Copy to clipboard" and "Run a command" when clicking json chat message? This is what I've tested but only the last setClickEvent is applied and not both
TextComponent text = new net.md_5.bungee.api.chat.TextComponent("TestMessage");
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/command"));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, shortcut));```
Basically I have a list of texts that I want to allow a user to copy to their clipboard and I want to send them a custom notification showing them what they have copied using the actionbar and thats why I want to run a command along with the copying to the clipboard, the command handles the notification about what text they just copied
no, the action that is performed is controlled by the action tag of the component, which can only have one value at a time
gotcha, I'll have to scrap the idea then unless something changes in the future that allows it to be possible, thanks for confirming
can i somehow get an download url through spigot api or spiget?
when a Chicken Jockey is spawned from a spawner, is it spawning a chicken ridden by a zombie or a zombie riding a chicken?
🤔
from one point of view, it's all three
it's spawning a zombie
fuck
the spawn logic then rolls a die and determines that it should ride a chicken
both entities are spawned
what are you doing
i want to disable chicken jockey spawning
listen to entity spawn event, check if the entity is a chicken and is being ridden by a zombie
ok
Hello!
I am trying to make a plugin in 1.16.5 than does something after a player sneaked for 5 seconds. I tried to make it with the PlayerToggleSneakEvent and did a scheduler in the event running for 5 seconds and it breaks if someone unsneaks. But it didnt work anymore when more than one Player were sneaking at the same time. Anyone an idea how I could do it, so that it works for more players at the same time? Thank you!
thats how I was trying to do it
you need to store the sneaking player UUID against the task id, then you get the right task to cancel based upon the player.
new BukkitRunnable() {
int ticksRunned;
@Override
public void run() {
ticksRunned++;
if (!player.isSneaking())
cancel();
if (ticksRunned != (20 * 5))
return;
// do stuff when player is sneaking
}
}.runTaskTimer(plugin, 0, 1);
yeah thats an even better version but I think it overwrites it somehow if others are doing it to but I dont know
I just told you how to do it for multiple players
Yeah I saw it but dont really understand do you have an example maybe?
I'm making a queue plugin where an entire server is dedicated to the queue where they are frozen and invisible in a void and can not chat or move. I was thinking of just spawning everyone in the same cords, is that a bad idea? i know 2B2T have a plugin like this, but they spawn the player on a long line. Is there any good reason for placing players on different cords or is the same?
if the player is invis, sure i guess.
like hided using Player#hidePlayer or something
It stops them from seeing each other
You could hide them, yeah
@opal juniper yeah atm i have all player hidden, but my i'm more curious if it is bad to have a lot of players in one cord
Umm, well lets think about it
Would you rather only have a couple of chunks loaded or hundreds as they wait?
You could even just have the 0,0 chunk loaded and unload all others manually
@jeffmcjefferson So a chunk can not get overloaded? I'm somewhat sorry if this is a dumb question 😅
Afaik, no….
Just have like 4 chunks loaded but cancel unnecessary packets maybe
Could you not just use the method under world?
@opal juniper i have no idea what the "the method under world" is?
It’s like world#unloadChunk(x,z) iirc
how can i simplify this? https://paste.md-5.net/lemegalawo.cs
its a lock command
something is wrong when i rightclick a block like dirt it gives a EventException null
bcs it has no state i assume
Well, you could start by ruling out some blocks
Which blocks do you want to lock?
Just Chests?
line 9 checking for NOT a TileState, then setting a TileState in a local scope so it can never be used
same with blockstate, you define and set it in a local scope
line 7 is not setting teh actual blockstate, its setting is own local blockstate
well how do i fix it?
line 7 Delete BlockState from the beginning.
ow yea forgot that
you never even use teh TileState you create up there
line 19 creates its own
line 35 never checks for a valid TileState
actually nothing from line 11 up is ever used in the code below
well block is used in line 22
What is the custom Block data that allows you to use a custom texture for a variant of a block type?
I swear there was a way
texture packs?
Yep, found it
customModelData
indeed!
idk how to setup one tho
oh it doesn't work on blocks
no
Yeah but i would like it to work like a block ><
look this i edited some things (btw the MagmaBuildNetwork.playersWantingLock is a list with the players that executed the command)
https://paste.md-5.net/yofuruvoxu.cs
Bruuuuh wtf happened here its like minecraft just gave up
barrier block in the armor stand head and like put a carrot on a stick that has customModelData on the armor stands head?
interesting idea
line 18 change to if (tileState == null) return;
line 23 use blockState instead of block.getState()
line 9 delete, and always set teh state
i seen people do different models of guns and stuff with carrots on a stick so its possible
line 29 use p instead of getting the player again
Hey, can I ask here for help about git with intellij ?
do not call it twice
line 33 use p instead fo getting player again
why is it so hard
sure
iknow im fixing the basics now
line 36 use tileState
pfft, if you don't use git by writing the machine code needed for it yourself are you even a real developer smh
don't call blockstate twice
don't create a new key each time
don't expose the player list publicly, create an accessor method
don't use a list for it, use a set, you don't want duplicate elements
clean your if spaghetti
also with customModelData u can change the model of a item in it so u can have multiple models but u can just put the block model on it
assess these issues and it should be fine
ok :b
So i'm new with git and I created a new branch named "test" as you can see on the first screen, but I don't understand why the branch isn't displayed as the second screen :/
u pretty much can make anything with datapacks and texturepacks
But the branch test is displayed on the right side ? All the way at the top next to master
The part where it actually branches off will not happen until you commit something on that branch
That isn't on your main braNch
Right now, test and main are identical
why is this always true?
Because every block has a state
private final NamespacedKey key; //assign in constructor
@EventHandler // Lock method
public void onContainerClick(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
Player p = event.getPlayer();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
BlockState blockstate = block.getState();
if (!(blockstate instanceof TileState) || !(blockstate instanceof Lockable)) return;
TileState state = (TileState) blockState;
Locable lockable = (Locable) blockState;
PersistentDataContainer container = tileState.getPersistentDataContainer();
if (MagmaBuildNetwork.playersWantingLock.remove(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
container.set(key, PersistentDataType.STRING, p.getUniqueId().toString());
blockstate.update(); //apply the lock!
p.sendMessage(ChatColor.DARK_GREEN + "Locked!");
} else {
String lock = container.get(key,PersistentDataType.STRING);
if (lock != null && !lock.equals(p.getUniqueId().toString())) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "You cannot open this!");
}
}
}
fix'd
uhu
well, aside from fucking indentation
xd
notepad doesn't do well with indents
thanks i'll try it
yea
spot the differences
then rationalize the differences
if you don't know why something is different, ask about it
correct my faults ._.
;-;
BrOOO
that stupid
ugly
cunt
dickking
bot
keeps warning
me
for
stupid
shit
maybe you should spam less
don;t type the same thing twice, or all caps
type like me, so many typos you never type teh same thing twice 🙂
ow yea i think its Lockable not Locable
i said all caps cuz i was saying why u use notepad and then it deleted it then i tried to say it again without all caps and then the bot warns me again