#help-development
1 messages · Page 828 of 1
So is the point to reduce the mute duration??
So if you got muted by litebans, you can unmute yourself by spamming messages in chat?
unmute? not. reduce duration of mute? yes
not in chat
I feel like "player tries to bypass mute with book" would be an easy tempban lol
That is the most utter rubbish i have heard in a while...
im also checking swearing/advertising in books, signs
Why bother with trying to prevent that, just yeet the player
I'm glad I'm not the only one having a hard time here
well my english is not perfect
Ok so if i write a mod which spams the server with chat packages each tick, i can basically unmute myself in no time.
That's ok just makes it harder to help haha
you understood it wrong. what litebans does is when you do /mute player 3h it sets player's mute time to 3h so if he had mute time of 7d it will set it to 3h (reducing it)
or i explained it wrong
hm
as i know
So you're trying to prevent the fact that it will reduce the time muted yes?
yeah
Ah i understand what you mean now.
So your code should be something like this:
if(!litebanAPI.isMuted(player)) {
litebanAPI.mute(player);
}
(Pseudocode)
This should reference the ismuted method in order to detirmine if a player is muted, then based on that check or others you may want to add, it will mute the player. You'll have to tweak it to your preferences
i already hooked into litebans api. what im trying to do is add support for every bans plugin with checking with some easy method (if there is any)
or maybe i will just check if litebans has setting not to override mute durations xd
Little question, would you guys know how to generate a world with no big patches of water?
I already put the world sos that it only generates dark forest biomes but i still have big patches of water
how would i handle transfering data bettwen :
- Game server
- Lobby server
i have an idea but not sure if its correct :
in game server , when a player kill someone for example or win a game .. etc , it will increase the [local stats for the SWUser instane] by 1 , and when a game end before sending the users of the game to the lobby server , the game moudle plugin will save the data to the global stats in mysql server and when a player is loaded in the lobby server moudle plugin , it will load the data with the new kills
That will not be possible unless you specifically support them
what about this idea
You'd have to use every api you could think of that implements admin functionalities then add support
That is incredibly messy and error prone.
How would you track unmutes?
if player types in chat (that means he is no longer muted) then ill remove him from muted.yml
they should be removed from muted.yml when the mute duration is over
not when they send a message and they are allowed because the mute is over, it should be directly correlated with the mute duration instead
Hm. That would be possible. But there might be plugins which intercept packets instead of cancelling this event.
wdym
well players type in chat alot
I mean soon my skywarz plugin will be revived, in that I do it similar to what you describe. You locally cache the specific match data of a player and push the increment to the database when a player dies or when the lobby ends.
what if i dont
I get that but based on the idea of a mute functionality they should be unmuted when the punishment is over. not when they chat
will it break something? hm
yeah ik
then ill have to track unmutes too :/
Thanks , for answering , can i use redis for that?
or no need to over complicate it?
I think you should just rely on the litebans api to handle muting durations and what not, theres no point to make extra work storing/handling mutes/bans/etc when litebans already does that for you
@charred blaze just store the player id with the Unix timestamp of when they finish their punishment. Have a Bukkit task constantly checking against online players (or even better have it tested when a player chats or a player runs a command for whether a certain player is muted or not)
It's a very simple overall thing to do, but maybe I misunderstand what the issue is
yeah that could work, but why is my idea bad
Can you quote your idea?
I thought his issue was that when the player is muted if you try to mute them again for example: (player has 7d mute currently, when you /mute them for another duration the 7d gets overwritten by the most recent duration) which I think he is trying to prevent
yeah
well ain't an issue, you just check if the player is already in the map of muted players. If true -> add the input duration to the already existing Unix timestamp
when admin mutes someone store muted player's name in muted.yml. and when player chats remove them from muted.yml
This should be your fix @charred blaze
Small Lifehack: use Duration from java util time
With this you can easily add and translate Unix timestamps
^ and really simple implementation as well... I'd think it should be at most 20 lines
im not coding punishment plugin
why is this idea bad
Yeah it's a very easy thing
Listening to the chat event > scheduling
Storing player names is not good for after 1.8
yup exactly
Ok, uuids
That's what I meant
Storing player names is never good 🙂
But make a centralized method for removing a player from the muted map, so you can easily test on multiple events
centralized method? wdym
As in don't put your remove and caching logic in the listener, but outside in a sperate utility / handler
why
ah
ok
So you don't have code duplication?
so will my idea basically work?
Easy access, easy debugging and every benefit that comes from no code duplication
A method accessible to your plugin... one that will follow something like:
MutedMap = litebans mutedmap;
return mutedMap
}```
I believe something like this would give you access to mutedmap.add/remove
uhh ok
I don't know how litebans api works though, although the mutedmap could just reference the way litebans handles muted players
Guys
therefore centralized method to handle player cases related to if they are muted or not
I found a good way to mute chat
Then there's no way to check if the player is muted unless you write the mute logic yourself
not that I can think of anyways
is there any method like .canWriteInChat?
I mean you can also just cache
you would use the asyncplayerchatmessage event I think and use check statements to determine if the player is muted or not and based on their chat you can also check for what their message is in order to implement antiswear logic then use the chat event to handle some player muting cases if you wanted to
You can force a player to send a message yes and then use the playerchat event to check if that string is the message you're looking for
hmm k
Wait what are you even trying to do @charred blaze
Trying to check if someone's muted
@quaint mantle
without hooking an api
Apparently he's using litebans
And for some reason can't understand that without using litebans, you cant check for a player mute unless you write that logic out yourself D:
exactly D:
worst case just access the db yourself ig
Thats why it was suggested to use a centralized method for returning the mutedmap or whatever litebans uses to handle mutes
ye, always try and use the API first. Or just implement it by yourself
Mute system is really easy to do with enough knowledge
tbf mute logic is really simple
Imma be toxic and assume OP doesn't have the knowledge to implement it themselves, which is totally fine
It's like 20 loc
Yes it's not an issue but at the same time using another api would still be way easier
I stored my info in some random zombie's pdc
I got a zombie worth 80mb rn
Why tho 😭
good system
What if the zombie is being deleted
I would suggest using a database or config over a zombie 😭
That's like the last thing that would come to my mind
@minor junco using the basic p.haspermission should work with any perms plugin right?
Ye
What's the point of adding specific support? for example luckperms
more accessibility related to permissions or what?
I assume to access groups and parents and stuff
It's like luck perms is a wrapper around Bukkit permissions, so the core should work with default perms, but if you want to check on a higher level you'd need to access the api
Hmm I see
That's just me assuming from my standpoint, I might be wrong but that would really surprise me
I mean I'd imagine there are only some rare cases where the permission needed to be accessed like that...
yup
I assume you also get some perks and quality of life improvements by accessing luck perms API
As in code wise I mean
Perhaps adding permissions based on mechanics or something like that?
yeah idk
Then you'd need to have a perms api I think
unless you do it yourself but like..... who does that anymore
I mean I kinda just made a little wrapper for my plugin
LMAO
W/o adding or removing tho
Yeah that's fair it's always nice to have access
that would be so funny tho
Just lookup with array element asserted paths
entire server gets unbanned because a zombie died LOL
My assertions checks like against empty permission segments and what not, just a nice to have
.... you're using an 80mb zombie to handle player bans?? D:
Nah I actually upgraded
now I made a separate world
it's a void world, but 1 cobble stone is a 0, and 1 stone is a 1
ArrayPath is an implementation that is general use and has an internal array with a bunch of optimization
I have a string with Tag section, so how to get section of Tag using that String?
Like String a = "LOGS" i need to get Tag.LOGS
Tag it's interface btw
But again, just lookup nothing too fancy
Is that your own interface
oh
I assume what you're trying to do is create a static variable in Tag that references your LOGS Tag?
No
I have string like "LOGS"
and in Tag there is a Set in Tag.LOGS
I want to get this set
It's only theorically, the string is always different
I can't help u with that, sorry
don't use the constant names, use the tag's id
This API is expected to be deprecated some time in the future and have a better replacement, but it works still
Tag<Material> logs = Bukkit.getTag(Tag.REGISTRY_BLOCKS, NamespacedKey.minecraft("logs"), Material.class);
I like that setup it seems pretty simple for the most part and like you said highly optimizable
No constants for that?
Thanks!
Constants for what?
The Tag
Tag.LOGS. User wants runtime tag fetching though
Ah
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Just type in a name and click create...
bro in yt tutorial has this menu
Older version of IJ
He created a normal java project
i want this too
how can i create without maven
i did
Not possible. You probably had the Build system on Maven instead of IntelliJ
Try again and make sure you select the right Build system.
Perfect. Now you have a vanilla java project.
hi
but why his looks different
Already got minus points with that name 
bro
Typescript >>
Looks exactly the same to me (besides the gitignore)
damn i saw ty for help!
the ui-utils mod allows me to dupe on my plugin, the de-sync thingy makes it not recieve slot clicked event, how can i avoid that happening
Which version?
1.19.3
Wild name
Cancelling the InventoryClickEvent should prevent any clicking on the item, regardless of client synchronization.
yea
Well, yeah
lemme send gif
lol im german too
*Predicting a gif with creative mode
There are quite a few ppl here from de
Verify or upload somewhere
InventoryClickEvent using that event
de-sync literly closes the ui but keeps it open
Shouldnt matter. Item creation is completely server sided. If the event is always cancelled, then there is no chance for a client to do anything to this inventory.
oh
i can prove that it's not a ghostet item
i lterly logged out
and its still there
Are you in creative mode?
yea
...
creative inventory is entirely controlled by the client
Creative mode is fked because it allows client authoritative item creation
But can you create it in survival?
If you cancel the InventoryClickEvent, then there is no duping happening.
*Unless you introduce dupes with faulty code,
Myeah, it doesnt get fired if the click is cancelled.
nah it's fine
they are independent events afaik
yea
Sure, but if the click was cancelled, then the drag cant be fired.
for anti cheats, what mod would you recommend?
Hey,
I want to unload a world when all players left it and this without saving it.
So I used Bukkit.unloadWorld(bukktiWorldObject, false);
But this returnes false. I also tried doing it inside a runTaskLater to run it 20 ticks after the last player left so they are realy gone, but still not working.
Anyone any Idea?
If B extends A and both have a {} pre constructor, which runs first?
and if it's A is there a way to make some code in A run after the initialization of B finished without specifically calling it?
not extends constructor yk
wym
superclass constructors and initializer blocks always run before subclass ones
Superclass is initialized first
figures lol
Yoo, my code doesnt make sense because the same code works perfect on the other method. Whats actually happening?
cuz ur values in the 1st is the class attribute and in 2nd its the given Map<?,?>
just realzied bruh the issue
Why use Map<?, ?> instead of proper generic types
its a messing issue around variables between values from memory section and Map<?, ?>
im too dumb haha
wait, how do {} and normal constructors interact? Is it {A} -> public A() -> {B} -> public B() ?
super() is called first, then the init block, then the rest of the ctor
ah i see
on an entirely different topic, how do i make an anonymous class extending an abstract class inline again?
if i try 'new that' its not giving me the option to expand it
only saying 'make that not abstract'
eh thats the situation i found myself in
huh
like
the class doesnt have any abstract methods
thats just there that you realize 'making an instance of this class doesnt make sense'
side noet
then why are you using abstract class https://cdn.discordapp.com/emojis/606563938838249482.webp?size=48&name=eyes_sus&quality=lossless
Access modifiers in java or java access modifiers such as private, default, protected and public with examples applied on data member, method, constructor or class.
a yes wouldve sufficed lol
thought you might need a refresher on all of them 🤷♂️
nah, i remember the rest
its just that i never use that one
except right now i guess
its the method registering specific things that should REALLY be done in the class registering it, or the whole point of the class is gone
also prevents stuff from ending up where it shouldnt
on another unrelated side note, is the 'empty class' (like, the class that just contains a method) possible for main only, or for other classes as well? There's something that should REALLY be done in a different class, but is one giant method
public class main {
public static void main(String[] args) {
double temperatur = 25.5;
if (temperatur >20 ); {
System.out.println("Angenähm");
} else {
System.out.println("Kalt");
}
}
}
i get error java else without if
ohhh ty
You do not know ? is, so it's not valid when you insert those values
so right now im like 'public class setup{ register(){ /* code */}}
Tbh having class called Setup seems a little weird to me
well yea
im registering a bunch of things there, it initializes objects of another class and pools them
hence the question
there a way to just have one big method
as as separate file i mean
Remove the semicolon from the if
No, everything in java must be contained inside of class
I don’t understand the question
java<some recent version> can do void main(){} as the only text in a file
That isn't case for kotlin tho😏
Only main afaik
As main goal of that jep is to make it easier for students
How are you supposed to reference that if it’s anything other than the main method?
Java makes fun :))
I don’t know any way to have a method outside a class
if i have a kind of object, how do i get the constructor of this object's class and create a new instance of it?
thanks, i will try to
I think its like some trick for beginners to lul them into a sense of security
before getting slapped in the face
what do you think about making a mysql table with :
- uuid , mode , kills ... etc
and each user will have 3 or 4 coulmns
- uuid,solo,10,... etc
- uuid,doubles,5,.... etc
and so on, is this good and is there better alternative?
huh?
Uuid (identifier), singles, doubles.
Uuid, 0, 10
you mean , soloKills , soloWins ?
but isn't that goona be too much data ? and queries?
It’s still be the same amount of querirs
Remember you can select the data u want in sql statements etc etc
that's why i did it in the row insted of coulmns .. so i can just use smth like :
SELECT mode from ... WHERE mode = ?
isn't that better?
Not really better or anything
iam making it for a big plugin .. so i want it to be perfect as possible ..
Just design it so uuid is the primary key
its
But this doesn’t work then
but if its a pk , it will not create new one xd? for each uuid , mode , stats . ?
its not sorry
Your primary key must be (uuid, mode) then
yes i do have that
That works but it‘s kinda unnecessary
When you could just combine the data into a single row
with soloKills, soloWins , doubleKills, DoubleWins? .. etc?
two questions - how much data was it again before the client crashes, and is it possible to check how much data currently is present in a player-data section, for example ender chest, inventory, or a specific item in those?
how would i detect if someone is using world downloader on the server and is downloading the world?
Yep, if you have a lot of fields you can think about splitting them up
But a new row for 2 values is not necessary
u cant. a good oen is 100% client side
you'll need to force them to run a custom client and then look at all the packets going into their client and what they're doing with them.
or that
you're looking at a very invasive anti-cheat here. You're best off doing some ring 0 kernel anti cheat like valorant
that way you know they can never be downloading your world if it loads before the OS 🧠
wait how does this work then https://www.spigotmc.org/resources/antiminimap-bukkit-bungee.1046/
probs with a packet for the mod?
like it says 'server disabled'
apparently also disables worldDownloader
likely the case for worldDownloader to
hmm
however that's a botch solution seeing as one could simply use another mod and just not tell the server or declare itself
All the information a client needs to copy a part of the world is already send when they load chuns
depending on your usecase what you want might just be custom worldgen
huh?
does PrepareInventoryResultEvent not have a way to get the items you put into it?
Been thinking about making my own parser for chat stuff recently. And afaik using regex is kinda a naive solution in many cases. Essentially I would want something like
<green>this text is green
I've been running through ideas in my head and I'm not really sure where to start. I read a couple resources on parsing and I know for sure I need to do tokenizing.
So I make tokens essentially e.g. <green> is my token. However as I scale I'm not really sure how to deal with parsing the tokens themselves. I feel like re-parsing the tokens contents once I've already looped over them is kinda wasteful. But parsing the token's content as I read it at first is equally difficult seeing as I have no clue where to apply the stylized contents to. Kinda looking for maybe pointers or resources. Most of the stuff I've found is directly related to programming languages and I have kinda been cross referencing these resources for ideas of design.
Could just use MiniMessage
i mean, if you have a specific set of tokens, why not group the tokens into categories (color, shape, etc), then search and index for those tokens? if <> denotes a token, it cannot appear inside one without breaking the outside one, so you should get a String, and lists of all tokens and where they start?
The question is how you'd find them, but even if you scan for them naively i dont believe thats an issue
why
I don't think you can do it at a runtime because the plugin is compiled
for commands probably yeah
commands
Use the commandMap
so i figured out my earlier issue, but... it doesnt mention if the inventory at that time already contains the result or not. I'm assuming no, can anyone verify?
I'm already
but I can't figure out on how I could prevent my commands from being registered
as of:
the commands are by default assigned to the JavaPlugin object
so it prevents like Essentials and stuff from overriding it
can someone review this code?
package org.gargamel;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.jetbrains.annotations.NotNull;
public class permissionHandler implements Listener
{
@EventHandler
public void Handler(PlayerCommandPreprocessEvent e)
{
String message = e.getMessage();
Player executer = e.getPlayer();
String[] array = message.split(" ");
if(((array[0].equalsIgnoreCase("/alert")) || (array[0].equalsIgnoreCase("/gsmp:alert"))) && (!executer.hasPermission("gsmp.alert")))
{
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.DARK_RED + "You do not have access to that command.");
}
if(((array[0].equalsIgnoreCase("/gsmp")) || (array[0].equalsIgnoreCase("/gsmp:gsmp"))) && (!executer.hasPermission("gsmp.get")))
{
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.DARK_RED + "You do not have access to that command.");
}
if(((array[0].equalsIgnoreCase("/rickroll")) || (array[0].equalsIgnoreCase("/gsmp:rickroll"))) && (!executer.hasPermission("gsmp.rickroll")))
{
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.DARK_RED + "You do not have access to that command.");
}
if(((array[0].equalsIgnoreCase("/song")) || (array[0].equalsIgnoreCase("/gsmp:song"))) && (!executer.hasPermission("gsmp.song")))
{
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.DARK_RED + "You do not have access to that command.");
}
}
}
well visually it looks quiet unreadable
why are you not using the internal command handler for this?
It doesn't follow naming conventions
also why are you using the preproccess event
and why not store array[0] in a variable so you're not repeating it all over again
and maybe have just one if
tldr
statement
just make one class per command
that way, the sorting and the permissions are both handled by spigot for you
i want to make it work that if you dont have permisson its dosent tab completes the command (so i set up permmisons in plugin.yml) but if you type the command it will show no-permisson message and **will not show **"unknow command"
for example my plugin overrides the /gamemode command. But I can't really redirect it to a vanilla CommandExecutor
also I hate how by default event variable is called just "e". this is stupid. i always rename it to "event" because its more clear of what im even referring to
You could just set the no permission message to unknown command
so when someone disables a command in the config and it unregisters in from the CommandMap, the /gamemode command is left incapable of execution
If you want to handle tab completions for specific command use the TabExecutor in the command class
playerChatTabCompleteEvent maybe?
No
and I would like to avoid overriding the command in the command preprocess event
Its something called playercommandsend or something
it sends a list of server commands on player join
to delegate to like /minecraft:gamemode
which can then be tabbed
Instead of trying to unregister it. Just register it if it's not disabled
the code works.. i just want to know if there is any more efficient way of doing that
well
people usually dont type commands in BIG
if you assume that you can just use a switch
But it'll still override the minecraft /gamemode
if it's just in the plugin.yml
ah wait a sec
Yeah don't have it in your plugin.yml
String.toLowerCase(Locale.ENGLISH)
unless I make only one command and make a delegating system for each of them
just register it in to the command map if it's not disabled
just cast ur string to lowercase before checking it
means switch and less if-then chaining
what about the permissions?
wdym?
it's like that in the plugin.yml. Do i need to add a permission check to each of the CommandExecutors?
no
given that n entities are loaded currently, is there an approach faster than O(n) for checking on a movement event if a specific entity moved?
basically, can you bind events to entities in less-than-O(entitites_loaded)-time
⚙️
wait im dumb
I made my first Java ,,Programm,, today I’m learning since some days
public class Party {
public static void main (String[] args) {
int guests;
Scanner scan = new Scanner(System.in);
boolean weiter = true;
System.out.println("Anzahl der angemeldeten Gäste: ");
guests = scan.nextInt();
while (weiter) {
System.out.println("Gast anmelden(1). abmelden (2), oder Programm beenden (3)");
int value = scan.nextInt();
if (value == 1) {
System.out.println("Wie viele gäste möchtest du hinzufügen?");
int guetsplus = scan.nextInt();
guests = guests + guetsplus;
System.out.println("plus gäste: " + guetsplus);
}
if (value == 2) {
System.out.println("Wie viele gäste möchtest du löschen?");
int guetsminus = scan.nextInt();
guests = guests - guetsminus;
System.out.println("gelöschte gäste: " + guetsminus);
}
if (value == 3) {
weiter = false;
}
}
System.out.println("Anzahl der Gäste: " + guests);
}
}
if I set target to some entity (entity.setTarget(null), will that be passed to EntityTargetEvent
can you not block the crafting of specific recipes using PrepareItemCraftEvent? it doesnt have a setResult, nor a setCancelled method?
do i need to use the craft event itself? that seems kind of inconsistent with the anvil prepare event and enchant prepare events, which can be 'blocked' in some way
ah you have to change the result
wait wat you cant?
tf
ah result in the inventory. i wasnt aware the interface had that
seems cleaner to just remove the recipe itself, but yeah
no
i need to block it based on the input item NBT
like, making you unable to craft enchanted stuff back into unenchantet for example
Yeah you set result in the inv
on that topic
why do those not share a superevent
cacheConsumer(PrepareInventoryResultEvent.class, event -> {
for (ItemStack i : event.getInventory().getContents())
if (DataHandler.hasCommonFlag(i.getItemMeta(), CommonFlag.UNCRAFTABLE)) {
event.setResult(new ItemStack(Material.AIR));
return;
}
});
cacheConsumer(PrepareItemEnchantEvent.class, event -> {
for(ItemStack i : event.getInventory().getContents())
if(DataHandler.hasCommonFlag(i.getItemMeta(), CommonFlag.UNCRAFTABLE)){
event.setCancelled(true);
return;}
});
cacheConsumer(PrepareItemCraftEvent.class, event -> {
for(ItemStack i : event.getInventory().getContents())
if(DataHandler.hasCommonFlag(i.getItemMeta(), CommonFlag.UNCRAFTABLE)){
event.getInventory().setResult(new ItemStack(Material.AIR));
return;}
});
it just seems a bit weird and i have triplicate code
*a useful superevent
Well you repeat the same loop thrice
tru
side noet
my IDE shows me the internals of the Enum i use to store those flags
(the powers of 2)
is there a way to make it not show the attributes of the enum value?
like the enum constant
huh?
like i didnt want to put a massive switch there and i also didnt want to add a case every time i do a new enum
my way to store it is to use a number, where each bit represents a enum value
but now its showing up internals that arent relevant outside the enum class
can i somehow mark the constant as internal
I still don't understand the issue?
What are you even saying...
Also can't you just use public int getEnumBitmask() { return 1 << this.ordinal(); }?
I mean you ought to know how to configure your IDE.
is this a good or bad way to handle a piece of armor which permanently applies speed?
well yes, but that adds one more operation, doesnt it? It's limited by the amount of data you can fit into a number either way, so why should i do it like that
considering when i tell it to enable soft wrapping with the filter '*' it does NOT enable soft wrapping, no, i do not know how to configure my IDE
i just dont know if this is safe
I would say this is a rather poor approach.
Is that feature even called soft wrapping?
no
its about something else
but it doesnt accept my config soo...
i do not know how to config my ide
the settings are in fact not settings
Instead of stopping the task, you can simply start one task which has a collection of players (or their UUIDs) to tick.
This task is started once the server loads and never stops.
You simply add or remove players that should be ticked to this task.
oh that's smart
Eclipse calls it "Code minings", though uh, I have that feature more than disabled
You could also just give them the effect infinitely when they equip it
💀 yeah I could
And remove it when they unequip it
There’s an event for that
Why not store the value in a final field then? The rest will be inlined by the JIT-compile due to the small method size anyways, so that will be as fast as you'd get
welp it doesnt exists in IntelliJ but considering your pfp imma not ask about that
isn't ther a lot of what ifs
arent the ordinals or whatever theyre called already effectively final?
is Bukkit.getPlayer(UUID) o(1)?
also howd you do that?
Yes
Like pretty much any other class?
I mean if the armor event is coded well there shouldn’t be any what ifs
public enum MyEnum {
ENUM_A, ENUM_B, ENUM_C;
private final int ordinalMask = 1 << this.ordinal();
@ApiStatus.Internal
@Contract(pure = true)
public int getOrdinalMask() { return this.enumMask; }
}
wait
Just for inspiration:
public class ApplicablePotionEffect {
@Getter
private final UUID playerId;
private final PotionEffect potionEffect;
public ApplicablePotionEffect(UUID playerId, PotionEffect potionEffect) {
this.playerId = playerId;
this.potionEffect = potionEffect;
}
public void apply() {
Player player = Bukkit.getPlayer(this.playerId);
if (player != null) {
player.addPotionEffect(this.potionEffect);
}
}
}
public class PotionTask extends BukkitRunnable {
private final Set<ApplicablePotionEffect> applicablePotionEffects;
public PotionTask() {
this.applicablePotionEffects = new HashSet<>();
}
public void addPotionEffect(Player player, PotionEffect effect) {
ApplicablePotionEffect appEffect = new ApplicablePotionEffect(player.getUniqueId(), effect);
this.applicablePotionEffects.add(appEffect);
}
public void removeEffect(UUID playerId) {
this.applicablePotionEffects.removeIf(effect -> effect.getPlayerId().equals(playerId));
}
@Override
public void run() {
this.applicablePotionEffects.forEach(ApplicablePotionEffect::apply);
}
}
Woops. A bit big.
Meh, why would anyone complain?
im pretty sure ordinals break if you do it like that, which is why im using the constant ordinal instead
like break if you add another enum value
Oh yeah, they ought not be used for anything like a savegame system
But if you just append new enums at the end of the list, nothing will break
Just always add new constants to the end :p
that seems a bit volatile
You just cannot have more than 32 entries if using ints or 64 entries if using longs
if i accidentally add it elsewhere it bricks itself
Eclipse will warn you if you attempt to sort an enum
IJ probably isn't that stupid either
im aware. im doing this to be able to reduce the enum into a primitive type
while guaranteeing the same inputs result in the same outputs even if the implementation changes in the meantime
Well I mean it is pretty hard to accidentally brick enum order.
i might insert a value between two others to keep it readable
I think an enum might not be the right choice for this.
If you really think you might mess it up still, add an note to future self. Otherwise, uh configure your IDE properly or explain your issue more clearly so I can hunt down the setting for you (why is it that IJ users always have configuration issues? Is eclipse extinct?)
it's ok if I make a singleton for this right
well, i wasnt curious about a specific setting, im pretty sure that exists somewhere, probably under the name 'ordinal' somewhere. i was wondering if theres some sort of annotation i can give the enum such that the values are only visible to the enum class
oh, you wish to supress the visibility of the automatically generated ordinal method?
Sure. The absolute proper way would be to use a manager singleton with a method to apply all effects, and
using the runnable purely as a heartbeat for this method. Adding and removing should be done by the manager.
This way the runnable doesnt need to be stored anywhere and the manager can be a singleton like usual.
no, reading out the value is required (EnumSet <-> int conversion). I want to block it showing the number after the enum because that is meant for internal use only
so it shouldnt show up in the javadoc for the enum
yeah that's what I weas thinking about
setting the boolean of your while to false to cancel the while loop is possible, but the statement break; suits it better
ARE TICK METHODS OUT YET
I dont think so. But you are free to take a look at the
?stash
the stash is stinky
Use the changelog viewer then
what that
View the Bukkit, CraftBukkit and Spigot changelog.
public class ItemFlag {
private static ItemFlag[] IDENTITIES = new ItemFlag[0];
public static final ItemFlag HIDE_ENCHANTS = new ItemFlag(1);
public static final ItemFlag HIDE_ATTRIBUTES = new ItemFlag(2);
public static final ItemFlag UNBREAKABLE = new ItemFlag(3);
private final int id;
private ItemFlag(int id) {
Preconditions.checkArgument(id >= 0 && id < 64, "ItemFlag ID must be element of [0-63]");
Preconditions.checkArgument(Arrays.stream(IDENTITIES).noneMatch(flag -> flag.id == id), "ItemFlag ID must be unique");
this.id = 1 << id;
IDENTITIES = Arrays.copyOf(IDENTITIES, IDENTITIES.length + 1);
IDENTITIES[IDENTITIES.length - 1] = this;
}
public int set(int flags) {
return flags & this.id;
}
public boolean isSet(int flags) {
return (flags & this.id) == this.id;
}
@Override
public boolean equals(Object obj) {
return obj instanceof ItemFlag other && other.id == this.id;
}
@Override
public int hashCode() {
return this.id;
}
}
This would be a non-enum approach i thought about.
It never exposes the internal id.
oh interesting, i see what you're doing there. two questions tho
- shouldn't it run on long though if the max is 64?
- also, wouldnt it need to left and right shift it? where does that happen?
Ah yes. For int you only have 32 bits.
I dont see a reason to bit shift anything here.
Wait
i meant for the store
Ah yeah true
i dont see how the ids for (1+2) do not conflict with 3
In the constructor this.id = 1 << id;
then its 0-63 then
Right, the constraints change in that case
What's the best way to add someone to a luckperms group in code? Should I use the API or just run the command like this
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lp user " + " group add .....");
Node node = InheritanceNode.builder("mygroup").value(true).build();
luckPerms.getUserManager().modifyUser(...)
something like that iirc
definitely api lol
What on earth is that
title?!
93k downloads
oh i see
so that's with the api then i see
is there a guide on setting it up with gradle do i need to add it as a dependency
once I add
compileOnly 'net.luckperms:api:5.4'
}```
am I good to go
Try and se
neat
unrelated but are completablefutures a good way to handle async things, and would I want permissions modifying to happen asynchrounsly?
i cant spell today
not sure if you can, I'd advise against it
CFs are the bog standard means of doing things asynchronously if you want callback hooks or to return a result from an asynchronous function, but no, you can adjust permissions on the main thread
If you're updating a database, however, that should be done async
does somebody know which event is called when a player scrolls through his hotbar?
Can't check if it's a scroll vs a number though. Server doesn't distinguish between the two
it takes 2 ticks to update the material for held item or smth
i dont recall how i queued it
Oh. Well I think "item held" is a bit of a misnomer. It's better described as PlayerHotbarSlotChangedEvent imo. It's when the client says "alright, changing my selected slot to <slot>, pls update me, ktnx"
Probably not yet at the point where the item has actually updated
hey
for what is onLoad usually used for?
it fires right after or before? the server has been loaded but when is that
when is right before worlds are loaded
although way after bootstrapping process
personally I use it for loading configs and other plugin data
for loading configs? arent plugins loaded after the world loading. how does that work
plugins are loaded before worlds are loaded
some are enabled after worlds are loaded
Yeah i see it now. why are some loaded before and some after tho
can you specify that
all plugins are loaded before worlds load
enabling comes after loading
some plugins enable after worlds load, but you can specify in plugin.yml that they enable before that
so you enabled your plugin before world loading? I remember I actually tried to load configs onLoad and it gave me an exception of some sort and i didnt bother with it since then
I think it had to do something with classes not being initialized. hmmmmmm
onLoad -> worlds load -> onEnable
test syntax is so weird like the method names I will never get over this xD
@Test
void test_Trie_Should_Contains_Call_Correctly() {
final Trie trie = new Trie("one", "two", "three", "four", "five", "six", "seven", "eight", "nine");
assertFalse(trie.containsPartial("en"));
assertTrue(trie.containsPartial("e"));
assertFalse(trie.contains("eight$"));
assertTrue(trie.containsPartial("one"));
}```
I'm not quite sure its like O(N) but not really
well if it runs to completion its O(N) so yeah
its better than String#contains if you have like many inputs because O(N) is a much better complexity than O(N^2)
insertion time is O(N)
Contains check is O(N)
Which is great for mass string comparison
In computer science, a trie (, ), also called digital tree or prefix tree, is a type of k-ary search tree, a tree data structure used for locating specific keys from within a set. These keys are most often strings, with links between nodes defined not by the entire key, but by individual characters. In order to access a key (to recover its value...
most common use is a syntax tree
its important to know though that with Trie's you shouldn't store things inside of the Nodes its a naive approach
TIL it can be called a trie
String#contains is O(N^2) ?
i think its O(N*M) no?
iirc used to be the case where there would be different contains impls depending on java impl
N*M ye
That’s an Oof
Is it possible to check at not compiled 1.20.3 server code? Im trying to check the configuration code to be specific
What?
You want to check the default config files for 1.20.3 ?
What file(s)? spigot.yml ?
I mean the java files which are the providers for config api. Mainly checking the spigot configuration api because i want to see how they manage the paths and nested paths from yaml files
Mainly internal spigot code, but the one which already contains the implenentations
It’s all on stash
what is stash? I havent worked with it just know about Github and some others, is it some sort of repository system
?stash
But there isnt any spigot code there? 🤔
What you sent is for building spigot i dont need the compiled code
oh that, really thanks man
what else would it be called?
I mean it could also be called a Syntax Tree but that's a specific implementation of a Trie
Yeah I’ve only heard syntax tree
Or some other form of tree
Not Tree but with an I for some reason
Binary tree
my prof pronounces it try as to not confuse it with other trees lol
trie's aren't actually binary trees
because each parent node could have more than 2 child nodes. This violates a fundamental principle of a Binary Tree
I'm not attacking you, I'm just poniting it out
how can I make my database reads and writes asynchronous
to not run with the minecraft thread
I figure if it takes longer than the ticks it's going to freeze the server which isn't good
CompletableFuture or Bukkit#runTaskAsynchronously
I usually opt for CompletableFuture as its just better imho
you get much more API to work with
You can combine both, which I would recommend. If a plugin is disabled while you're fetching, the async thread you invoke with CompletableFuture won't stop
So go with runTaskAsynchronously & completable future's
@short pilot
I don't remember the commands
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
If you've dealt with Promises in TS/JS before, completable futures are basically the same
Yeah but I was thinking that the implementation and names are different, so I didn't use the phrase equivalent for that but yh in the end it is
How can I best check if player is in water, even if they aren't moving?
Atm I've got a player move event, but I'm using it to apply potion effects that obviously expire after a time
And if they're standing still, it won't fire again to reapply the efects
I advice not using the PlayerMoveEvent since it's triggered tremendous amounts of times
Just make a runnable that runs every few ticks
Is that more efficient than a move event?
Will solve your problem and will be more efficient
Yes
Ok ty
Since it's only being triggered once a few ticks
The PlayerMoveEvent is triggered so many times each tick
Player rotation, Player move, and stuff
Yeah thats fair, but from a semantic point of view
Yeah nah absolutely
Hello! I use Intellij ultimate with plugins "Minecraft Development" Anyone know why these don't get "spigot" icon even though I created it as a minecraft plugin module
btw, now the whole project disappeared 💀
?
What is it that I am not clear about? 🙂
I don't understand your situation
does anyone has the cuboid class made by illusion
What does that do?
just some utils for cuboid regions
like checking if they intersect
etc.
oh
I have created 4 new Modules with the "Minecraft" template, but when I opened the project again, it is no longer a project that works correctly as it is not recognized by the plugin (The plugin in intellij) that I use
Ah
The "HubTeleport" project doesn't get the icon or something else?
is this like a new thing?
i dont remember this
its been there a long time
bruh
Not exactly what I mean, these Modules are not recognized by the plugin I use in intellij
it probably hasnt indexed yet or have a spigot dependency
^
It has a correct pom.xml
Tried a bit quickly to just redo the HubTeleport-v1_20_R1 again and now it seems to work a bit unsure if it will stop working again like it did before
Why the hell does a hub teleport plugin need nms
is it good practice to always do try () catch for the prepareStatment?
for example :
so it auto close?
Yes
would this be a good way to check if player has moved into the region(in playermoveevent)
it would work, but early return if xyz from == xyz of to
so you don;t need to mess with the boundingBox at all if they are just looking around
alright thanks
Early returns would be better
so uh like this? (essentialy im checking if player either entered or left the area)
create Vector variables for getFrom and getTo so you don;tr do it over and over
but otherwise good?
at teh very top, before teh for loop
then return if fromVector == toVector
you don;t need to do anything in that code if the player has not moved
ohj i see
Vector fromVector = event.getFrom().toVector();
Vector toVector = event.getTo().toVector();
if (fromVector == toVector) return;
for(...```
@eternal oxide Is it ok to use PlayerMoveEvent?
Aren't they triggered like hundreds of time per tick
I mean couldn't you run a BukkitRunnable that runs every tick or few ticks
Would save performance
the plugin isnt for me so it doesnt matter
you'd end up running more code in a runnable than early return in the move event
its also simpler just to early return
You could get players in a specific world
And loop through them
Yeah I guess, but logic is still going to be ran
you could use a runnable if you are competent with caching
Wdym
For his use though, just creating two vectors in the move event is not much
I suppose
Whatever is preferred I guess
if his BB's were also bound to a full block I'd do the early return if getBlocK on to/from was teh same]
Also why not just make a variable for the boundingBox, getTo, getFrom and the player?
as long as it doesnt put tps to 5
maximum pay for minimal work 🙂
Try stress test with like 10-20 players and look at the TPS
@eternal oxide If you do end up using tasks, couldn't you run it on another thread for better performance?
yes you could, as you are not making world changes
that would be ideal actually
TPS won't drop either
multithreading tasks
th
i literally have nitro why
Can't use emojis here
Server doesn't allow
fortnite

Guys ! Help please
private void deleteUidDat(World world) {
File uidDatFile = new File(world.getWorldFolder(), "uid.dat");
if (uidDatFile.exists()) {
uidDatFile.delete();
}
}
Can this affect the visibility of the players? In the sense that for some reason, when teleporting, they do not see each other, although after updating the region, they see each other
How would I add a 2nd line to my chat hover ?
hi i need small help with redis :
it only send this 3 times and then stop
ofc this is in the proxy server :
bungeecord
why are you subsribing every 2 seconds
correct
it does send the user to the Lobby server .
when the game end , it send the debug messages but nothing happens
code?
and what debug messages are sent
in proxy part :
server info is not null .. connecting the user to lobby...
and in the sendPlayerToHub method it send this mesaage :
sending players to lobby"
and no messages on the redis debug?
let me debug it again and check
so only this is being sent :
Did some changing on the proxy side :
but it still not sending me to lobby :p
add more debug statements, figure out exactly how the code is running and whats happening where
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>```
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>```
how can i change the above dependency and plugin to 1.20.1?
i cant find it even if I check the repository
bru plz help why am I getting a NullPointerException where config is null
private static FileConfiguration config;
private final GriefAlert3 plugin;
// Constructor that takes the main plugin instance as a parameter
public ReloadCommand(GriefAlert3 plugin) {
// Use the plugin instance to get the configuration
this.plugin = plugin;
this.config = plugin.getConfig();
// Now you can use this.config to access the configuration
}
public static void reloadConfig() {
List<String> materialList = config.getStringList("noAlertMaterials");
// Convert the list of material names to an array of Material objects
GriefAlert3.nonAlertBlocks = new Material[materialList.size()];
for (int i = 0; i < materialList.size(); i++) {
GriefAlert3.nonAlertBlocks[i] = Material.matchMaterial(materialList.get(i));
}
List<String> placementAlertMaterialList = config.getStringList("placementAlerts");
// Convert the list of material names to an array of Material objects
GriefAlert3.placementAlertBlocks = new Material[placementAlertMaterialList.size()];
for (int i = 0; i < materialList.size(); i++) {
GriefAlert3.placementAlertBlocks[i] = Material.matchMaterial(placementAlertMaterialList.get(i));
}
}
}```
you cant use this.config on something static
and if you call the method before the constructor its going to be null
Rip so I cant access it from another class then
oh yeah that was the issue
I have it called in my onEnable
ok lemme try now I removed the this. from config in ReloadCommand
Ok fixed it epic
Hello everyone! Listen, I have a question. Is it possible to set up a WhiteList so that when a player who is not on the whitelist tries to join the server, they receive an error prompting them to undergo verification on the website: https://[your_website] ? And how can I make it so that clicking on the error immediately redirects the player to that website?"
That would be a #help-server question
I think the player preconnect event covers that. You can set the kicking reason and test whether the disconnect is because of the whitelist
No need
it works well with local repository! thanks
can i use nms without using a build tool like maven?
you can but its much harder
I wish I knew how, and if it’s even possible, I don’t even understand
maybe or not I can't figure it out
Sorry if there are mistakes, I communicate through a translator
which intellij keymapping is for 'close currently open file'? The ones im finding are closing the project window
like the name of the input is what im looking for
ALT+F4 😄
might be one of these
tried those thats why im asking, they both close the project window for some reason
i made sure to click on the file too
welp
i apparantly did in fact not
tf
Ctrl+F4
If not, you changed your keybinds at some point
nah i did not
its just that the cursor was blinking in the editor window
so i thought it had focus
it did in fact not have focus
eh
I often find myself typing stuff and somehow I'm typing in the project search field and not the file lmao
still better than light theme (geol cough)
xD
seriously what IDE ships with default light theme
no java ide that does that that i know of is any good
Eclipse iirc
theres also bluej, its similarly stupid
Netbeans too
And maybe NetBeans but I have not opened that since 2019
has exactly 1 redeeming feature
Yeah
What is it?
you can manipulate objects in a limited way without compiling and launching a programm
but the editor is shit
intellij can do that
For some reason light theme makes me feel like I'm working on Windows Vista when dark themes were not all the hype lmao
also i prefer to not burn out my eyes lol
And when an ide is shipped with default light theme it just feels like not a top notch quality product
A cognitive bias on my part lol
I mean dark means more elegance so understandable
to hotswap files at runtime just requires jetbrains runtime as the jdk and some startup flags with a debug config
Yeah
wtf
oh it gets worse
What is this
those boxes have a maximum width
Huh
LMFAO
I don't even dislike that 💀
and you have like [print (Long log] message);
Surely this is pseudocode and not just an inability to code java
i just grabbed an example image from google search
Is it even java
image search still works lmfao
Why shouldn't it?
I mean this ain't java can't be,
for each (var int I : 1 .. n - 1)
Yeah
googles recent curating of search fucks normal results
I see
acutally
Some Google alternatives, and what they are
Found on reddit (dont ask me where)
https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2Fwhat-the-google-overlords-dont-want-you-to-see-v0-lh2oayg3jh5c1.jpg%3Fs%3Db00fbbb9bfc8519493688032b69167a316b241d0
(* I have a backup of the image, if it gets removed, I can provide it. Ping me if that happens)
Damn, ty
this might be pin-worthy :kekw:
i keep forgetting that isnt on this server lol
i mean its not really code relevant lol
Ehh..
whatever
if i get banned I'm blaming you
@ivory sleet would you mind illuminating us with your opinion on this topic?
it doesn't include StartPage.com
If you make a single module for each version of NMS and you want to support sub versions eg 1.20.3. Do you have to make a separate module for these? And what do I do if 1.20.3 is not available? Likewise, paper users running 1.20.3 should not be able to use plugin or how to do it?
Wait, what do you mean now?
are we upto R3 or R4 for 1.20 now?
I can never remember as I don;t ever see teh CB part
.3 and .4 shares the same R3 package
R3 covers .3 and .4
you can join a 1.20.4 server with 1.20.3 client
it's only one critical bug fixed
The R version does not correlate to the minor version of the release.
But what should I do to support
- 1.20
- 1.20.1
- 1.20.2
- 1.20.3
- 1.20.4
unless 1.20.3 doesn't exist or what do you mean?
And 1.20 does not exist
we are currently on 1_20_R3 which covers 1.20.3 and 1.20.4
Okey, but how do I download BuildTools for 1.20.3 if I'm going to be able to support that version with NMS?
?nms
How do I download 1.20 then? When I ran it, it just loaded 1.20.1
--Rev
Waitn
1.20.1 is 1.20
Likewise 1.20.3 is 1.20.4
You can nolonger obtain 1.20
if i remember in NSM not exists difference.. its like a .4 its a patch for .3
So you mean that you don't have to do it for every sub version except for one?
it's one of those cases where 1.20 is pretty much identical to 1.20.1
You have to do it for every change in protocol
In 1.20s casw there are 3 released
1.20.R1 1.20.R2 and 1.20.R3
Okay, but then it is enough if I support 1.20 - 1.20.4 to have
1.20.R1
1.20.R2
1.20.R4
ok, but then I don't understand what they said that they had replaced 1.20.3 with 1.20.4 or something similar
i mean for the case 3. and .4 its the same things.. the only diff its a bugfix and only that
NMS not change a internal version.... for that its a "replace" in spigot...
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/51eea725f7b2b683ce04c7d2aeb76705086d78e6#pom.xml
sysout this to see what version you are using Bukkit.getServer().getClass().getPackage().getName().substring(23);
It means 1.20.4 supersedes 1.20.3 the difference between the two versions is one line of code thus making 1.20.3 obsolete both updates are the same internally minus that one line
Protocol version wasn't bumped
Minor updates shouldn't have a difference in their NMS so don't worry
Don't use get class please use what bukkit provides it gives you its maven version
Not necessarily true only in some cases this holds
Shouldn't, but they have in the past
