#help-development
1 messages Β· Page 739 of 1
But I thought size was fixed to amount of slots there are in general
yes it is
I think, you can just add an itemstack, get it's slot and then remove it. But idk if you need to update the inventory to do it. I don't think so
what if you have air slots in between
Yeah that was my problem
Oh
start loop at the end of contents, if not null, get π€
or air
π€·
I can't think about anything else
I deleted my local files and pulled code from my github repository. Afterward for some reason my imports are erroring. Any ideas why?
Maybe you didn't push local files before deletion?
I made sure to run git add ., git commit -m "message", and git push
prior
I mean you can check if those files are present on remote
When I made my plugin I was 16 and much less knowledgable of what I should have done. Now I am 23 and much wiser in regards to programming and its related sciences. Life's complicated, there's family, friends, job, hobbies, free time, relationships, etc and it keeps getting more complicated as you stack up routines that supposedly make your life better. It would be foolish to assume I am lazy and that's it, that's a counterproductive way to think of developers in this community.
I understand yeah
What's that button IntelliJ has
Invalide caches and restart or somethin
Or maybe it's just invalidate caches and then you restart yourself :p
IntelliJ gives you the option to restart it in the selection of which cache to invalidate
so just press that, happens from time to time in my case
Is there an easy way to disable unwaxing copper / stripping logs (so that if a player is holding an axe with blocks in their offhand, if they right click it'll place a block instead of unwaxing / stripping)
That cancels it but doesn't place the block
what block
The block in the player's offhand
oh
well thats just how the hand priority works
you can place it with code I guess but can be pretty buggy I guess
Yeah that's what I've got atm using blockfaces but I was curious to see if there was an easy way to do it
Ig not :(
I'm still able to build the plugin although it's saying the imports are invalid. Any help?
Thank you!! Seems fine now π
hey guys, I'm currently making a forge mod and I have a few custom packets to keep in sync with the server and tell other clients about stuff. Is it possible to make a bukkit plugin that would have the same behaviour allowing for users of the mod to see each other without needing a modded server and if yes, how?
Yes. That's what the message channels are for
hmm
registerIncomingPluginChannel() will let you accept packets from your Forge mod, registerOutgoingPluginChannel() will let you send them via Player#sendPluginMessage()
Thanks Mojang
Reading and writing the data in a way that Forge will understand it is a bit different though. They use Mojang's protocol format so things like varint and varlong exist
I have a class you can mostly copy/paste (a few extra methods in there that are VeinMiner specific but you can remove them) if you want some easy reading/writing
https://github.com/2008Choco/VeinMiner/blob/master/veinminer-common/src/main/java/wtf/choco/veinminer/network/PluginMessageByteBuffer.java
No-arg constructor to write, single arg constructor to read
hm
is it bad to add ExampleApi#getInstance when developing an Api?
or do i need to use PluginManagger#getPlugib
not really
or maybe static methods
You should have static methods for things
The only breakage you might get if you do that is reloading plugins. But the same applies if you do it differently and are not careful enough
thx
wait but with ExampleAPi#getInstance it should world right?
and instance = this in condtructor
As long as you don't store the value anywhere dangerously there is nothing to worry about
For mine API I like to have a setInstance method
Which will fail if the instance is already set, so nobody else can make use of it
But there are a bunch of ways to do it
any one know how can i do an animation with an item in spigot?
no like flying stake do some moves
Probably, but what would be more efficient is precalculating sin and cos given your variables don't ever change
Store the results in one or two arrays and iterate over them
i
They're independent to anything else in your loop
Could also store your max and increment in constants
The location can change, that's fine. But the fact of the matter is that you're only doing Math.sin(i) and Math.cos(i) but those i values are entirely unaffected by local variables. They're constant
Do max and increment get calculated each iteration
Actually the compiler should handle this given they are constants... right?
AffineTransform is AWT, no?
In that case I recommend against it. Could cause funky behaviour in headless envs or on macs
Okay, well in the snippet you send your i value is constant so they can be precomputed. So if you expect to use some other snippet where i is variable then don't bother
And if you're using radians, iterate in radians. It makes no sense to iterate in degrees if you're just going to convert to radians
It's nonsensical
It's funky
Not a headless one because why would you need a graphics package in an environment that can't display graphics?
Doesn't spigot kinda die on headless
Modern versions of Bukkit have JOML shaded so you can use that if you want
Paper sure doesn't. Spigot, idk?
Shade joml yourself
Also an option
Or use my funny maven resolver
No
No. JOML is quite massive
It's pretty much the standard graphical mathematics library
It's designed to be used for LWJGL games
Author of https://github.com/JOML-CI/JOML. GitHub is where httpdigest builds software.
Main person is this guy
That's John JOML
Good ole Johm JOML
I mean if we're being honest here, shading JOML probably isn't worth it if you expect to use only one class lol
This is what minimize is for choco
this offical? https://spigotmc.ru/
Prob no
lol
Definitely not lol
Website litteraly diffrent
i was think this spigot rus verison
demm
Probably just "if not Russian browser, block"
I'm tired of writing plugin instructions not in my native language(
most of the visitors are English people
I will risk
Hi I have a short question I am working with an InventoryClickEvent: The event only happens after all handlers are run through and it wasnt set to cancelled right? This means that anything I want to happen that needs the event to have already taken effect needs to be scheduled?
i'm 100% sure i know the guy who hosts this website
- right
- i don't get what you need
I have an item that should be updated whenever a clickevent happens. The item change checks for an inventory and what is in the inventory. The problem is that inventory can also change due to the click event. The way I have it now it would only show the newest change after another InventoryClickEvent
Because its pretty much a backpack and it shows the items in the inventory through a bundle so I still have to allow adding items to the inventory while then directly updating the bundle
well then why do you change item in backpack
if it's supposed to be a backpack
you probably should launch a scheduler after invclick
which would update item 1 tick later
User conditions are a little worse, but there are no restrictions on the sale of the plugin. (Reviews, etc.)
The question is how well the administrators check for viruses
That assumes they even do
Thats what I did and it works I just thought it might not be a good way but I guess I was wrong thx π
if this so well now this is will my favorite site
this site too
but rus my native
It seems like you can't post plugins there
i always thought so
yml is the best
it's the most readable
...
i don't think json is readable enough
It's a math library lmao
Yeah I was confused for a sec
i mean, it looks okay, but definitely not worth shading it for 4 config files
It is good enough for key -> value pairs, but once you have arrays it is not usable.
Velocity uses TOML and they're migrating to YAML lol
Forge uses TOML
Yeah, and to this day I wonder why
Yeah but at least they're in a different enough ecosystem
but then again, if the users get used to a specific config format, it is best to follow the standard for that platform
wait why lol?
if he was here he would say something like "have you seen ViperTomlLib its really good for configs"
Over at forge the standard is either use TOML or JSON5 or YAML or whatever
It is defo way more nonstandard than here
It was the only large software in the Bukkit community that used TOML so it was unfamiliar for most users wanting to migrate from Bungee
I dunno if they've finished the migration or not but I know they were talking about it some time ago
i always assumed the standard for spigot/bukkit is yaml
someone pr json
You could in theory add other FileConfiguration implementations
99% was yaml when i had a server
Just... y'know, why?
YAML is a JSON superset
why not
Can it work adequately with arbitrary-size arrays?
If you want your plugin to be the only one on the server to be in a different format then go for it I guess
Make things nice and confusing when you run a sevrer with plugins using 3 differnt formats
Especially when nested
thats why we pr it
Doesn't need to be in Bukkit natively
yes it doe
It provides you API to add it yourself in your own plugins
I mean I extensively use JSON or HOCON in my plugins
Ah okay nice
Fairs
Especially for I18N
whats hocon
JSON but with comments would be my summary
hocon these nuts
very mature colluthine
{
"_comment": "Hello! This is a community standard comment!",
"key": "value"
}```
Hey json can have comments
i was actually wondering how would json look with comments
If you use lenient parsing
i don't like it
Yeah, GSON has it
it would be great if gson impl a break line character for comments
but not sure how parsing it/beautifying would work
Hi, I need help with one thing i've been stuck at
I'm having a really weird problem: If I move an item really fast fom one slot to another sometimes only one InventoryClickEvent fires vs the normal two Events
Does someone know if this is intentional or something?
I want to make sure every player in the game's camera is stuck at one block
sounds easy
Like all the players can see what that block sees, even though they are in a different place and they control their characters elsewhere
Uh like a platformer game
like those old mario games
just listen for playermove if the player is in game and a check for not moving is, event.setto event.getfrom
Any advice on how I can get the player camera to do that?
i don't understand
You know the old mario games right?
like a spectator of a block?
You view mario from a third person perspective
oh hmm
I want all players in a game to view their character like that
so third person view of some character?
third person view of their own character
that sounds difficult from the server to enforce
Being able to control their minecraft character in third person perspective
that's just f5
theoretically you can just lock the player camera to a specific block right?
no
you cannot?
Not without a client mod
do you know an app with which you can make these models?
you can be a spectator and put a item in front, but it's so difficult, not even sure it'll work best
can we send links in the server?
you have to rely all the movements to the block yet the camera has to remain somewhat stable
if you verify sure
this is pretty much what i wanna make
the guy in the video codes a plugin and shows it for a split second but i do not really get the code
i can look it up
sounds easy
yeah
playermoveevent
and just set the yaw towards north
i think it's 0?
LEFTPLACE_ALL does not fire which makes 0 sense to me
i just watched the whole video, he pretty much tells you everything he did to make it
isnt it just a lazy Bukkit#getPluginManager#getaplugin
what
can u explain the setInstance method further?
u have a custom api, and the user can do setInstance once?
or u do setInstance yourself
I do it
From onEnable
You could also skip the method and set the instance via reflection
server runs on ticks
so sometimes it probably doesn't register during tick?
thats my tip
It should always fire
hi can i get some code help here?
Unless you are in creative, creative messed up the inventory events
can i ask some code related problems here?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Im testing it in survival and on a fast move from one slot to another only the LEFTPICKUP_ALL fires and not the LEFTPLACE_ALL
When publishing a plugin on the forum, is it allowed to use the link to the plugin's modrinth page as the external download URL?
i making a gem which will give speed in offhand but it isnt giving potion effect pls help
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import SpeedGem.SpeedGemItem;
public final class BlissPluginRemake extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
PluginCommand command = getCommand("GiveSpeedGem");
if (command != null) {
command.setExecutor(this);
getServer().getPluginManager().registerEvents(this, this); // Register the event listener
} else {
getLogger().warning("Command 'GiveSpeedGem' not found!");
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
ItemStack SpeedGem = SpeedGemItem.createSpeedGem();
player.getInventory().addItem(SpeedGem);
player.sendMessage("You received a Speed Gem!");
return true;
} else {
sender.sendMessage("This command can only be executed by a player.");
return false;
}
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
ItemStack offhandItem = player.getInventory().getItemInOffHand();
if (offhandItem == SpeedGemItem.createSpeedGem()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 99999, 2));
}
}
}```
this is my main class
i have another class which have the code for gem
if someone got free time then pls help me out
im new so i prob did smthing stupidd
for the sake of classes
please make seperate class for events and command
It's fine. Plugin is small enough
Any reason you're opting to use potion effects instead of attributes?
uh i dont know i just needed speed so went for potion..
try System.out.prints instead of potions
just to check whether the listener even works
oh ok let me see
ItemStack itemStack = new ItemStack(Material.EMERALD);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, new AttributeModifier("my.special.emerald", 2.0, AttributeModifier.Operation.ADD_NUMBER));
// Your other methods
itemStack.setItemMeta(itemMeta);```
Speed boost should be handled automatically. No need for potion effects at all
You can play around with that number or with different operations
ok so i just replace it with all the stupid potion effect i tried to did in Held Item event?
Correct. You can remove your listener entirely
The reason your method wasn't working by the way was because you were comparing ItemStack instances with == instead of itemStack.isSimilar(itemStack)
I would still opt for the attributes though. Just a bit cleaner
anything will help if it gives speed i can spend some time playing around with the value
You may want to set the slot for the attribute
Lest you get a big mess on the tooltip
You could hide the tooltip entirely if you wanted
uhm
Also an option yeah
itemMeta.setItemFlags(ItemFlag.HIDE_ATTRIBUTES)
oh ok
so its just ```java
private static ExampleApi instance;
@Override
public void onEnable() {
instance = this;
}
public static ExampleApi getInstance() {
return instance;
}
@worldly ingot im sorry for ping but i have sperate class for the Gem i added the code you said its kinda not working idk what i did now ```package SpeedGem;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import net.kyori.adventure.text.Component;
public class SpeedGemItem {
public static ItemStack createSpeedGem() {
// Create the Speed Gem (renamed Amethyst Shard)
ItemStack speedGem = new ItemStack(Material.AMETHYST_SHARD);
ItemMeta speedGemMeta = speedGem.getItemMeta();
speedGemMeta.displayName(Component.text("Speed Gem"));
speedGemMeta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, new AttributeModifier("SpeedGemAbility", 9.0, AttributeModifier.Operation.ADD_NUMBER));
speedGem.setItemMeta(speedGemMeta);
return speedGem;
}
}
Does anyone know how to get the client version? Not the server. It doesn't matter if it's using NMS or just the spigot api.
ClientIntentionPacket provides the protocol version
Hello, does anyone here know if there is an event that is triggered when a rail changes direction?
probably redstone something event
when the client joins i think it says the client version
i assume the check whether the client version is correct is done server side
Is there a way to add the html files in the resources to my plugin folder?
Plugin#saveResource
Is there a way I can control on which slot a item is added to the players inventory?
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
// Check if the player has a Speed Gem in their offhand
ItemStack offhandItem = player.getInventory().getItemInOffHand();
if (!offhandItem.isEmpty() && offhandItem.isSimilar(SpeedGemItem.createSpeedGem())) {
System.out.println("Speed GEm Detected");
// Get the player's movement speed attribute
AttributeInstance movementSpeed = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
// Check if the attribute is not null
if (movementSpeed != null) {
// Apply the "Speed" attribute
AttributeModifier speedModifier = new AttributeModifier(
UUID.randomUUID(), "Speed Gem", 9.0, Operation.ADD_NUMBER);
movementSpeed.addModifier(speedModifier);
}
}
}``` can someone help me this event is not executing
i tried using an Sysout line to see if the event works but the event is not just working
public void onEnable() {
// Plugin startup logic
PluginCommand command = getCommand("GiveSpeedGem");
if (command != null) {
command.setExecutor(this);
getServer().getPluginManager().registerEvents(this, this); // Register the event listener
} else {
getLogger().warning("Command 'GiveSpeedGem' not found!");
}
}``` i even have registerd the event
How can I make sure a task timer starts at a certain time?
I want to start it at the beginning of an in-game day. i know how to find that, but I'm just not sure how to delay the start to that point.
Try this
```java
public SpeedGemListener(Plugin plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
// Check if the player has a Speed Gem in their offhand
ItemStack offhandItem = event.getPlayer().getInventory().getItemInOffHand();
if (!offhandItem.isEmpty() && offhandItem.isSimilar(SpeedGemItem.createSpeedGem())) {
System.out.println("Speed Gem Detected");
// Get the player's movement speed attribute
AttributeInstance movementSpeed = event.getPlayer().getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
// Check if the attribute is not null
if (movementSpeed != null) {
// Apply the "Speed" attribute
AttributeModifier speedModifier = new AttributeModifier(
UUID.randomUUID(), "Speed Gem", 9.0, AttributeModifier.Operation.ADD_NUMBER);
movementSpeed.addModifier(speedModifier);
}
}
}```
Main Class:
@Override
public void onEnable() {
new SpeedGemListener(this);
}
run taskTimer on that value
have you registered it?
I know this. but I don't know how to use.
also use java
Obviously?
?
I mean is there some way to delay the start? Another task is the only way I can think of.
plugin.saveResource("yourFile.html", false);
isn't there a delay before first run right in the tasktimer
BukkitScheduler#runTaskLater?. if you want repeats the BukkitScheduler#runTaskTimer has an initial delay
assuming that would even be accurate
doesn't work
?
That's what I'm thinking I would have to do, runTaskLaster than have it run the task timer
does the file exist in the jar
I guess that's the only way
use something like winarar or 7zip to check
Tf is this method. is it even exist? π
why when runTaskTimer has an initial delay.
it's literraly in the runTaskTimer
I still want it to run forever after that, I just want it to start at exactly the beginning of a day
why are we ignoring the delay parameter?
long delay
use a ScheduledExecutor not the Bukkit Scheduler if you want accurate periods
I can read very wellβ’οΈ
happens
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
code is this
File file = new File(plugin.getDataFolder(), "files/key.html");
File file1 = new File(plugin.getDataFolder(), "files/style.css");
if (!file.exists()) {
plugin.getDataFolder().mkdirs();
plugin.saveResource("files/key.html", true);
}
if (!file1.exists()) {
plugin.getDataFolder().mkdirs();
plugin.saveResource("files/style.css", true);
}
that isnt how you should do it
i think yes i wanted to send all of my code but i am not able to send it here
File filesFolder = new File(plugin.getDataFolder(), "files");
File keyFile = new File(filesFolder, "key.html");
File styleFile = new File(filesFolder, "style.css");
if (!keyFile.exists()) {
plugin.getDataFolder().mkdirs();
plugin.saveResource("files/key.html", false);
}
if (!styleFile.exists()) {
plugin.getDataFolder().mkdirs();
plugin.saveResource("files/style.css", false);
}
Did you try the code I sent you?
yes im trying
in your code this.plugin is giving error "cant resolve symbol 'plugin' "
remove the line this.plugin = plugin; from the constructor
that should fix that error
okay i will try to see if it works..
Doesn't work
does your jar include said resources
also you probably need to mkdirs the filesFolder
saveResource will preserve directory structure
he likely doesn;t have a files folder with resources in his jar
resources
files
Key.html
style.html
It looks like this.
thats your project not your jar
can i somehow add two items on fish hook?
or at least replicate the pulling behavior?
uh its not working... im not able to send my full code here either..
?paste it
ok
lol
why
somehow i dont think you should be touching assemble
ditto
what assembler nasm x86-64 I've been learning I can print out things and take input
@remote swallow https://paste.md-5.net/yuwasunije.java this is the link
sorry ik im dumb
I need a bootloader in 64 bit assembler, I have a project for college
you have 2 java plugin classes, you have 2 onenables in 1 class
?learnjava before using an api
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.
hi, can you explain why it doesn't claim 16x16 but 8x8
public class Commandclaim implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
GriefPrevention griefPrevention = GriefPrevention.instance;
World playerWorld = player.getWorld();
int playerX = player.getLocation().getBlockX();
int playerY = player.getLocation().getBlockY();
int playerZ = player.getLocation().getBlockZ();
int x1 = playerX - 28;
int y1 = playerY;
int z1 = playerZ - 16;
int x2 = playerX + 16;
int y2 = playerY + 319;
int z2 = playerZ + 28;
UUID ownerID = player.getUniqueId();
CreateClaimResult result = griefPrevention.dataStore.createClaim(
playerWorld,
x1, x2, y1, y2, z1, z2,
ownerID,
null,
null,
player
);
if (result.succeeded) {
player.sendMessage("Claim created");
griefPrevention.dataStore.saveClaim(result.claim);
} else {
player.sendMessage("Imposible to create claim");
}
}
return true;
}
}
ooh that's some weird math
I was a bad student and they told me that if I didn't write this, I would be expelled.
i have 1 for Events and one for like main thing
You can't do that
Should I maybe ask someone from the spigot team it seems like a Bug to me
you should only have 1 class extending java plugin, you should only have 1 on Enable
oh ok
as said, learn java or atleast the basics before using spigot
okay
what should I do?
If you actually need to write a bootloader (in which case I'm sending best wishes for your mental health), you can take a look at this guy who's got a detailed tutorial on how to create a rather simple operating system, where he explains how they work on a very low level: https://www.youtube.com/@writeyourownoperatingsystem
And I advise you take a look at this helpful wiki: https://wiki.osdev.org/Main_Page
If you study the process and do some additional research, you'll maybe be able to go with it somewhere
and guys, who can help with blueprints? i'm new in ue4, and want make crouch for my game
You are taking two extremes and putting them very close
You asked for help with a bootloader and then for help with unreal engine lol
i would love to know how ur managing to do a bootloader in assemble but cant make a project in intellij or read docs
This sounds like a hood joke
bro, i'm first day in unreal engine
This is some really weird code. Why do you have a fixed offset for y?
What happens when the player stands way up high or on bedrock.
zbll ur sus
In what way π
in the way of message deletion
Well the server is English only so I deleted the message swiftly after I assumed it could be read
fair
do min max on the locations and then - n on min and + n on max
.
i can change player size, but, i don't know how to check isCrouching or no?
I put y = 319 for the build limit because I believed that the player could build if the claim was not 319 high
This is none of my business, but if you're about to get expelled if you don't create a fucking bootloader, you should probably put away Unreal Engine for some time and start working
what ?
i dont understand
wait nvm, it's on playerlocation
The deadline for completing the task is until the new year. I will probably have time to do this a little later, but now I would like to know the answers to the remaining questions
focus on one thing at once
i need create game.
unreal engine will take a fraction of the time making a bootloader will
No actually do not
I personally can't work on one project at a time because I get bored with it
thats called adhd
So I have to work on two projects concurrently so I always ahve something to work on
Shit
int size = 16; // Diameter
int rad = size / 2; // Radius
Block base = player.getLocation().getBlock();
World world = player.getWorld();
int upperX = base.getX() + rad;
int lowerX = base.getX() - rad;
int upperZ = base.getZ() + rad;
int lowerZ = base.getZ() - rad;
int lowerY = world.getMinHeight();
int upperY = world.getMaxHeight();
i change this for test if is not the number but is not this
help me make this blueprint..
okay thank you i will try
i have a slight feeling the answer ur looking for would take a few min to find
InventoryClickEvent not firing
it does not work
Btw, I can't help with much else, so I'll just send you two definitive links to help you with a bootloader (because that's all I can help with lol):
https://wiki.osdev.org/Bootloader_FAQ
https://wiki.osdev.org/My_Bootloader_Does_Not_Work
You might want to start with these when you decide to get to work with the bootloader. After you're done with the base of the project, you can refer to the rest of the wiki & to the YouTube channel I've sent you
What do you expect to happen and what is actually happening?
exists
sorry. I mistakenly wrote this code in the reload process.
Hi, im doing a mute plugin with this as my mute handeling. Ive already tested the background stuff, the mutes are getting saved to the file and ive checked it with both java and bedrock accounts (geysermc) and its not working on both.
Problem: I can still write although being muted:
Code: ```java
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
}
you really provided
very little
information
also why would you need to not ignore the cancelled event? What if there's another antiswear plugin that has already cancelled that event and you just allowed him to speak if he's not muted
well there is no other antiswear plugin, i just need to know why i can still speak, although being muted in the system
you never showed the system
just one event of two classes with having no idea of how they work
don't worry, we won't steal your code
Just from looking at this I can tell it's not worth stealing
doesnt make sense, right..
This is the backend data:
Data:
UUID1_CENSORED: '2023-10-07 22:16:59'
UUID2_CENSORED: '2023-10-07 22:30:55'
Shows both my accounts are banned until 2 hours
MuteUtils.muteCheck does this:
public static boolean muteCheck(Player p) throws ParseException {
Date dNow = new Date();
Date endMuteDate = getDateTimeFormat().parse(DataConfiguration.INSTANCE.getData().getString(DATA + p.getUniqueId().toString()));
int test = Objects.requireNonNull(endMuteDate).compareTo(dNow);
if ((test == 0) || (test < 0)) {
unmutePlayer(p);
return false;
}
long timeIn = endMuteDate.getTime() - dNow.getTime();
p.sendMessage(ChatColor.AQUA + "Laser Network " + ChatColor.GRAY + "Β» " + ChatColor.RED + "You are currently muted! Please wait " + TimeUtils.calculateTime(timeIn));
return true;
}
that is... unnecessarily complicated
you can just
save the System.currentTimeMillis + theMutedTimeInMillis
Have you tried printing MuteUtils.checkMute
well im a beginner and i try to learn by projects, even if its more complicated, if i understand it better i can learn more
Also this looks like static abuse
doing that rn
and if the current System.currentTimeMillis is less than this then don't allow speach
that's how I made the most basic mutes
but they're also pretty much the fastest this way
I'll try to help you then
wtf is 'static abuse'?
Using static methods?
Using statics in context where there shouldn't be static
such as?
read this
MuteUtils
im working on it
I don't see a reason as to why not use it statically
It's having some state, which shouldn't exist in static context
so im using this
if(MuteUtils.muteCheck(e.getPlayer()) == false) {
e.getPlayer().sendMessage("is false");
}
and am writing in chat, but nothing happens, even if i change it for true in the if clause, nothing happens
i recommend you use ! in front instead of == false
it might be the muteCheck wrong
did you register the event listener?
in the onEnable() method?
yes
this si onEnable
public void onEnable() {
try {
registerCommands();
} catch (IOException e) {
throw new RuntimeException(e);
}
DataConfiguration.INSTANCE.init(this);
DataConfiguration.INSTANCE.saveData();
Bukkit.getPluginCommand("tempmute").setExecutor(new mute());
Bukkit.getPluginCommand("unmute").setExecutor(new unmute());
Bukkit.getPluginManager().registerEvents(new PlayerListener(),this);
}```
are there perhapse any return points before this?
yeah, this is definitely static abuse, I see it now
I would like that when I do /claim it claims an area in 16x16 is not in 8x8
but for now it'll suffice
well there are only 2 returns
1 = false if the dates are before each other or same
and true are when its not the case
before each return
well i can send a message if that helps with debugging
well i get an error now when i use plugman to reload the plugin
!paste
/paste
how does this work
?paste
do you use PlugManX?
And what is happening?
Why dont you just claim the chunk the player stands currently in?
if I have a final itemstack and I give it to players then modify something about that itemstack will it affect the itemstack in every inventory?
the final modifier on item stacks really doesn't do anything other than say yo I can't assign this reference to anything else while I use it
yeah I just said it so you understood the context of what I'm saying
ItemStacks are inherently mutable so always be careful when editing them while there is no guarentee it will change all of the items as some are coppied it may adversly affect some
so does it not clone the itemstack when you add it to an inventory?
it depends
sometimes its really weird
it could hold the reference, it could clone it or it could merge with another stack
is it possible to do that?
so ill get back to my problem tomorrow, im tired rn
nooo
without removing their files
I only want to stop it's loading for certain points in time
and then load it if I deem them fit
cuz there is Player#loadData
Sure
im looking at this resource https://www.spigotmc.org/threads/image-to-particles.455677/ and im a bit confused on how they load the image
File file=new File(getDataFolder(),"test.png")
what is getDataFolder() ?
oh well if I'm completely like setting their inventory then it should be cloning it right
JavaPlugin#getDataFolder()
your main plugin class
yeah but where do i put my image
but how ? If you know
in your plugin file
wait, lemme help you out
public static File getWithJarCompiledFile(String s) {
File f = getPluginFile(s);
try (InputStream in = YourMainClass.class.getClassLoader().getResourceAsStream(s)) {
Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
return f;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static File getPluginFile(String fileName) {
String path = YourMainClass.instance.getDataFolder().getAbsolutePath();
new File(path).mkdirs();
return new File(path + File.separator + fileName);
}
do
Get the chunk, get its corners, done
File imageFile = getWithJarCompiledFile("test.png");
if(!imageFile.exists()) imageFile.createNewFile();
and just add whenever to your project a test.png file
is it in this folder
so this?
yes
Chunk chunk = player.getLocation().getChunk();
World world = chunk.getWorld();
Block lowest = chunk.getBlock(0, world.getMinHeight(), 0);
Block highest = chunk.getBlock(15, world.getMaxHeight(), 15);
// The rest should be self-explanatory
bump
oh yeah chunk.getBlock is a thing
Itemstack funny
Can't you just .clone
jree fava
Wut
Hello, do you know if there is a way to have the messages in the server's language without creating a translation file ourselves?
for example I have: String description = event.getAdvancement().getDisplay().getDescription();
but this message is in English, I would like it in the language of the server
impossible
jk
ig not possible
impossible again
tho you can try sending player some shit via packets
so client will adapt it to user's language
more work than translation files
it's not to send in minecraft but in discord webhook
translation files or code a discord bot
does server actually have region/language setting tho?
should have it it'll make it easier
i can help u make the custom languages @odd lark
imagine getting achievements on chinese when playing on russian client
It's a shame, since Minecraft offers to choose your language, I told myself that there was the possibility of recovering their translation file. it is to send the messages of death and success
are u using google translate
you can always get player's current locale tho
but your code will turn into ```java
if locale == english {
} else if locale == chinese {
} else {}```
In itself I don't need to know the language of the player since the messages are intended for a French discord server
Hello! Anyone have any idea why my server crashes after I reload the world if asking about the highest block?
so, I first delete the world with "deleteFolder" and then create it with "createWorld"
TestPlugin.getInstance().custom.getHighestBlockAt(1, 1)```
```java
public static void createWorld(String worldName, Long seed, ChunkGenerator generator) {
WorldCreator wc = new WorldCreator(worldName);
if (seed != null) wc.seed(seed);
if (generator != null) wc.generator(generator);
Bukkit.createWorld(wc);
}
public static void deleteFolder(String worldName) {
World world = Bukkit.getWorld(worldName);
if (world == null) return;
File folder = world.getWorldFolder();
Bukkit.unloadWorld(world, false);
try {
FileUtils.deleteDirectory(folder);
} catch (IOException e) {
e.printStackTrace();
}
}```
you need to load the world with a player ig
I've tried it doesn't seem to help unfortunately, but everything works if I just restart the server then there's no problem with the server crashing
well then restart the server after reloading world π
So if I find the highest block immediately after generating the world without restarting the server crashes, if I restart the server after generating the world it works
Half the point with my plugin though is that you shouldn't need it :/
You need to wait until the spawn chunks are generated before getting a block in a newly generated world. Otherwise you get a deadlock
with a block being requested in an ungenerated chunk, triggering the generation which is already pending.
USE ANNOTATIONS
Also something to consider: FileUtils.deleteDirectory(folder) will delete the files directly, but there might still be file handles for
a few milliseconds. So loading a world with the exact same name might cause problems. Spigots world loading system is simply not designed
for dynamically loading/unloading worlds. It has always been causing unpreventable lag.
works on spigot, not on paper iirc
I remember I had that issue with my skyblock stuff
and my cosmos project still trips up so I've just decided to give it a temp tag and delete tagged worlds on startup too
Yeah i also just tag worlds for removal and try to not reuse folders
Doesnt prevent the lag from IO on the main thread tho
I've gone with the "copy .mca files and load the world" approach before
that was fun
Okey, but how does the chunk load when restarting the server and can it be simulated somehow so a player doesn't have to go to the world? Or how would su be done to solve this?
The spawn chunks get generated if the world has the "keep spawn loaded" property enabled
If you get several blocks in an unloaded chunk and change them in one tick, it will only load that chunk once, right?
Yes
But if I want to retrieve a block that is maybe at 1000, 1000. So since it's not spawn chunks will it still work?
It will cause a bit of lag but it should work. Just wait a few ticks.
ok, is "keep spawn loaded" a boolean in org.bukkit or?
It's in the spigot.yml
[ERROR] Plugin org.apache.maven.plugins:maven-checkstyle-plugin:3.3.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-checkstyle-plugin:jar:3.3.0: 1 problem was encountered while building the effective model
[ERROR] [FATAL] Non-parseable POM C:\Users\User\.m2\repository\org\apache\maven\plugins\maven-checkstyle-plugin\3.3.0\maven-checkstyle-plugin-3.3.0.pom: only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT seen \u0... @1:2) @ line 1, column 2
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Why are you getting this error when trying to compile bungeecord?
is there a way to store data within an item or block, like a string, and make it persistent? meaning, it keeps that data or info when putting it on and breaking it again, when changing inventory, idk moving it through hoppers, etc
How do we get the βverifiedβ role? because I followed all the steps but I got nothing and it is impossible to start again because the bot tells me that I have already verified
?pdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
it seems to be just what i need, but will it still work when, for example, plugins that modify blocks with nms and magic, like fast async world edit, make modifications to those blocks?
Hello, question: Is there a reason or a way to avoid "'\t" in Bukkit to show a weird character
I need to tabulate a formatted string, but its showing me a weird character
add 4 spaces
hello, does anyone know why spigot().setUnbreakable(true) mess with the item texture?
i want to allow players to place mob spawner in survival, so i did this in the block place event
BlockStateMeta blocKStateMeta = (BlockStateMeta) event.getItemInHand().getItemMeta();
CreatureSpawner itemSpawner = (CreatureSpawner) blocKStateMeta.getBlockState();
CreatureSpawner blockSpawner = (CreatureSpawner) event.getBlockPlaced().getState();
blockSpawner.setSpawnedType(itemSpawner.getSpawnedType());
blockSpawner.setSpawnRange(itemSpawner.getSpawnRange());
// all setStuff(getStuff) methods...
blockSpawner.update();
it works, but there is no method to specify things like if the mob has passengers, armor, effects, etc. how can i do that? is there a way to literally just copy everything and thats it? or even better, disable the "no survival spawners feature"
btw i should clarify i dont fully understand the difference between block state, block data, block metadata, item meta, and all that stuff, not very familiar with spigot and minecraft development in general
Why would you need to use spigot()#setUnbreakable?
Is this not offered with item meta
does anyone here happen to hae experience with changing default vanilla terrain generation?
I think maybe there is an easy way using nms but I havent found it yet
I just want to make smaller biomes
I'm using 1.8.9 (I know, old version)
who knows unsupported version unsupported behavior ig
yeah, but was looking for someone who maybe had a similar issue? lol
Unbreakable stuff has a different predicate in a resource pack
seems like it was an incompatibility between plugins
Is there any symetric Minecraft font?
has anyone here used kong as a load balancer before?
i have wanted to try it out but no sadly
Anybody up to date on the recent Advancement NMS changes? I think I need to serialize the advancement now, but I don't know how.
Yea, I need toasts, but I'm struggling with the new requirements for criteria.
Criterion used to provide a ResourceLocation. There was no need to serialize since the impossible trigger just ignored it anyways.
Now it's requiring a manual trigger which doesn't even provide the ability to set a predefined one.
@remote swallow If you have this figured out, just shoot me a message.
Is there a way to get TPS?
All i know is the difference from loading and advancement from gson lol
wtf is that theme
Watchu know about it? I might end up doing that if I can't figure out this part.
[WARNING] The POM for org.apache.maven.plugins:maven-checkstyle-plugin:jar:3.3.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for BungeeCord-Parent 1.20-R0.2-SNAPSHOT:
[INFO]
[INFO] BungeeCord-Parent .................................. FAILURE [ 0.610 s]
[INFO] BungeeCord-Chat .................................... SKIPPED
[INFO] BungeeCord-Config .................................. SKIPPED
[INFO] BungeeCord-Event ................................... SKIPPED
[INFO] BungeeCord-Protocol ................................ SKIPPED
[INFO] BungeeCord-API ..................................... SKIPPED
[INFO] BungeeCord-Log ..................................... SKIPPED
[INFO] BungeeCord-Native .................................. SKIPPED
[INFO] BungeeCord-Query ................................... SKIPPED
[INFO] BungeeCord-SLF4J ................................... SKIPPED
[INFO] BungeeCord-Proxy ................................... SKIPPED
[INFO] BungeeCord-Bootstrap ............................... SKIPPED
[INFO] BungeeCord Modules ................................. SKIPPED
[INFO] cmd_alert .......................................... SKIPPED
[INFO] cmd_find ........................................... SKIPPED
[INFO] cmd_kick ........................................... SKIPPED
[INFO] cmd_list ........................................... SKIPPED
[INFO] cmd_send ........................................... SKIPPED
[INFO] cmd_server ......................................... SKIPPED
[INFO] reconnect_yaml ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.836 s
[INFO] Finished at: 2023-10-08T00:29:24-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-checkstyle-plugin:3.3.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-checkstyle-plugin:jar:3.3.0: 1 problem was encountered while building the effective model
[ERROR] [FATAL] Non-parseable POM C:\Users\User\.m2\repository\org\apache\maven\plugins\maven-checkstyle-plugin\3.3.0\maven-checkstyle-plugin-3.3.0.pom: only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT seen \u0... @1:2) @ line 1, column 2
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
why?
corrupt pom by the looks
C:\Users\User\.m2\repository\org\apache\maven\plugins\maven-checkstyle-plugin\3.3.0\maven-checkstyle-plugin-3.3.0.pom
why not GameRule.DO_INSOMNIA?
does anyone know why this code would have the rotation apply instantly and not over time (interpolation isnt working)
BlockData blockData = Bukkit.createBlockData(Material.DIAMOND_BLOCK);
bd.setBlock(blockData);
Display disp = (Display) bd;
transformationLeft(p, disp, new Vector(0,1,0), 0.785F);
}
public void transformationLeft(Player player, Display entity, Vector axis, float angle) {
entity.setInterpolationDuration(40);
entity.setInterpolationDelay(-1);
Transformation transformation = entity.getTransformation();
transformation.getLeftRotation()
.set(new AxisAngle4f(angle, (float) axis.getX(), (float) axis.getY(), (float) axis.getZ()));
entity.setTransformation(transformation);
}``` no stack dump or anything
read the docs
and raise an issue flag to the original github source
because of the non-ticking nature of that entity, it doesn't have a built-in position time interpolation that such entity has
what entities do tick? I saw someone do this with oak stairs
All entities essentially tick since that's what makes them entities. Do Block Displays not tick? That'd be interesting to see
they must tick as they have an interpolation/delay
import SpeedGem.SpeedGemItem;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
public class SpeedGemEventListener implements Listener {
@EventHandler
public void AbilitySpeed(PlayerSwapHandItemsEvent event) {
System.out.println("Event is working!");
// Check if the player has a Speed Gem in their offhand
ItemStack offhandItem = event.getPlayer().getInventory().getItemInOffHand();
if (!offhandItem.isEmpty() && offhandItem.isSimilar(SpeedGemItem.createSpeedGem())) {
System.out.println("Speed Gem Detected");
// Get the player's movement speed attribute
AttributeInstance movementSpeed = event.getPlayer().getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
// Check if the attribute is not null
if (movementSpeed != null) {
// Apply the "Speed" attribute
AttributeModifier speedModifier = new AttributeModifier("Speed Gem", 2.0, AttributeModifier.Operation.ADD_NUMBER);
movementSpeed.addModifier(speedModifier);
}else {
}
}
}
}``` i have made a modifier for whenever somone have this item in their offhand but how do i remove the modifier if they remove this item from there offhand or dont have it in there offhand?
.
public class scoreboard implements Listener {
@EventHandler
public void scoreboardJoin(PlayerJoinEvent e) {
new BukkitRunnable() {
@Override
public void run() {
Player p = e.getPlayer();
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard sb = manager.getNewScoreboard();
Objective obj = sb.registerNewObjective("spawn", "spawn", ChatColor.YELLOW + "Survival");
Score nick = obj.getScore("Nick: " + p.getDisplayName());
Score przerwa = obj.getScore("---------------");
przerwa.setScore(5);
nick.setScore(4);
Score rank = obj.getScore("ranga: soon");
rank.setScore(3);
Score przerw = obj.getScore(" ");
przerw.setScore(2);
Score serv = obj.getScore("PlaygroundHC.PL");
serv.setScore(1);
p.setScoreboard(sb);
}
}.runTaskTimer(plugin, 0, 100);
}
}```
why this code doesn't work?
?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
?paste
Nobody can help you if you don't tell us what is not working
i can't see scoreboard in game
and an error
cannot find symbol
in ide
and i can't build jar file
becouse of this error
bro stop spamming
i saw your code 4 times
thanks but this is not what im looking for
just like that lol
?paste
https://paste.md-5.net/ibugaliwiq.java i can't see scoreboard in game
server engine: paper 1.17.1
?whereami
but if im not mistaking I think you need to set the DisplaySlot
how i can get Fish by "PlayerFishEvent"???
tnx
because "@EventHandler
public void PlayerFishBreak(PlayerFishEvent event) {
Player player = event.getPlayer();
if (!isInProgress(player)) return;
if (!playerFishHashMap.containsKey(player)) return;
if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
EntityType fish = event.getCaught().getType();
if (!fish.equals(playerFishHashMap.get(player))) return;
}
int remaining = remainingAmount.get(player) - 1;
remainingAmount.put(player, remaining);
addBossbar(player, "Β§aΒ§lYou still have to fish "+ remaining + " " + playerFishHashMap.get(player).toString().toLowerCase() + "!", maxAmount.get(player), remaining);
if (remaining == 0) {
stopQuest(player);
addBossbar(player, "Β§aΒ§lYou have completed The quest!", 100, 100);
Bukkit.getScheduler().runTaskLater(QuestAddon.getInstance(), () -> removeBossbar(player), 20L);
}
}" dont go?
please properly format it
so whats the problem
When I remove the hook from the water it detects as if I have fished.
yea but nothing will be caught
Indeed, but he counts me as if he captured something
your code still counts it because ur only returning out of the event when the player HAS caught a fish
when its anything other then caught_fish also return out
i would do it like this:
if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return
EntityType fish = event.getCaught().getType();
if (!fish.equals(playerFishHashMap.get(player))) return;
π
Is there a way to set the block loot in code
something like
table.put(Material.Cobblestone, new ItemStack(Material.Dirt));
Ill dm you when i get up and send the diff
Is there a way to give players the operator items tab without giving them OP?
what do you mean with operator tab
The Creative Operator Items Tab
???
What?
nvm
I have the same error it claims in 8x8
public class Commandclaim implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
GriefPrevention gp = GriefPrevention.instance;
Chunk chunk = player.getLocation().getChunk();
World world = chunk.getWorld();
Block lowest = chunk.getBlock(0, 0, 0);
Block highest = chunk.getBlock(15, world.getMaxHeight(), 15);
UUID ownerID = player.getUniqueId();
CreateClaimResult result = gp.dataStore.createClaim(
world,
lowest.getX(), lowest.getY(), lowest.getZ(),
highest.getX(), highest.getY(), highest.getZ(),
ownerID,
null,
null,
player
);
if (result != null) {
player.sendMessage("Claim créé avec succès !");
} else {
player.sendMessage("La crΓ©ation du claim a Γ©chouΓ©.");
}
}
return true;
}
}
Yo
I want to ask how can i redirect connecting player
To the server
Or run multiple proxies on the same port
And when player is connecting to one of them
It choose the proxy with less load
Its enough to have one proxy.
So im back with my Problem, to make it short: i can write although being muted by my mute plugin
What if you have 40 000 players and it might send 1mln packets per second?
Netty pipeline will do kaboom
Proxies optimized to work with a lot of people.
I don't mean to be rude but do you have actuall programming knowledge?
Or you just telling me what someone told you on the form
Or smt
this is my mute check player:
public static boolean muteCheck(Player p) throws ParseException {
Date dNow = new Date();
Date endMuteDate = getDateTimeFormat().parse(DataConfiguration.INSTANCE.getData().getString(DATA + p.getUniqueId().toString()));
int test = Objects.requireNonNull(endMuteDate).compareTo(dNow);
if ((test == 0) || (test < 0)) {
unmutePlayer(p);
Logger.getLogger("warn").info("test1");
return false;
}
long timeIn = endMuteDate.getTime() - dNow.getTime();
p.sendMessage(ChatColor.AQUA + "Laser Network " + ChatColor.GRAY + "Β» " + ChatColor.RED + "You are currently muted! Please wait " + TimeUtils.calculateTime(timeIn));
Logger.getLogger("warn").info("test2");
return true;
}```
Ive already checked my backend stuff works the mute things get saved to a file and that works, but it doesnt really check anything and the logging debugs dont get logged.
Although im muted i can write in chat
(cant send the picture)
ping if answer pls
this is horrible o0
Firstly start at naming your variables correctly
Player is player not p
Current Date is currentDate not dNow
yeah well then it's okay, I will give you some suggestions of why I think your code is bad:
- inproper variable names. "dNow" should be "now" or "dateNow". "endMuteDate" is a good name
- you're testing if test == 0 ||test < 0. Why not just test if it's <= 0 ?
- Logger.getLogger("warn") what's that?
- the method is called "muteCheck" so it should only CHECK for a mute - it should not be reponsible for sending a message
- the message should ofc be configurable
a good thing is that you used ChatColor instead of hardcoded Β§c things. But I wonder why are are you rethrowing the ParseException? Where does it come from? And why are you Objects.notNulling the endMuteDate ?
okay, well i understand the first but i dont want a config system because i havent learned it yet and only need to plugin for my own server so i dont need a config
yes
but i still dont know why the AsyncChat thing isnt firing and cancelling the packet
its not even showing the debug msgs
the message definitely should not be sent within the muteCheck method itself, or you shuold rename the method to checkMuteOrSendMessage or sth
I don't see you listening to any events in the code you sent
thats the event stuff:
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
if(!MuteUtils.muteCheck(e.getPlayer())) {
e.getPlayer().sendMessage("is false");
}
if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
}
}
i have done the "is false" for debugging
but its not showing
First you need to save somewhere the players that are mutted
So you should read it from the file in muteCheck method
print a message first line in the event. does it get printed whenever someone writes sth?
so i have a DataConfiguration class for that
Or put it when plugins starts from file to List and when plugins disable put list to file
thats what it does
btw your MuteUtils and DataConfiguration.INSTANCE would be considered "static abuse" by most people
i have heard that before but need to learn what it means
Don't use static all the time
what's the goal of your plugin? I suggest you rewrite it from scratch and we do everything step by step, then we can explain things to you better
Static is only for methods that you want to have acces all over your project
Like some MathHelpers etc.
i want to have a mute system, i already did ban, kick and unban
you prob wont like the others cause theyre very messy written
NO
Many people are going crazy whenever they see the static keywoard inside some source code. Thatβs ridiculous, because it alleges the people who developed Java were totally stupid. It is true that the static keyword gets abused by many people, but thereβs a difference between static abuse and proper use of the keywoard. What does...
Better way to do this.
interface MuteInfo {
/*
Returns time stamp
*/
long expire();
}
// database
interface MutedRepo {
MuteInfo getMuteInfoOf(UUID uuid);
void removeMuteInfo(UUID uuid);
}
//logic
public boolean isPlayerMuted(Player player) {
MuteRepo repo = myMainInstance.getMuteRepo();
MuteInfo muteinfo = repo.getMuteInfoOf(player.getUniqueId());
if (muteInfo.expire() > System.currentTimeInMills()) {
player.sendMessage("You muted blah blah blah, mute expires at " + SomeUtilParser.parse(muteInfo.expire()))
return true;
}
repo.removeMuteInfo(player.getUniqueId()); // order to remove.
return false;
}
|| π₯ ||
"static" is for things that do not need any instance access
Static is fast but its a also a fast way to write spaghetti code, as kittykat said, it quite literally means global. When things become global it becomes hard to isolate code which causes other code symptoms.
what you describe is exactly what is considered static abuse. "yo I made this static so I can access it from everywhere" NO
you should be passing an instance instead or use a proper singleton pattern
bedrock just crashed when i opened chat, like it
Some common allowed static usages are
- utility classes
- nested classes
- pure/stateless methods
- static factory methods
- singletons
- multitons
- constants
- immutable collections that live a long life
i get an internat error when i did this debug thing
You fucking idiot XD
a utility class is only a utility class if it does not require any instance of anything else, otherwise it's just a fake utility class
i have this:
public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
e.getPlayer().sendMessage("Test works");
if(!MuteUtils.muteCheck(e.getPlayer())) {
e.getPlayer().sendMessage("is false");
}
if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
}```
and now i get a error when i try to mute someone
sorry but I tend to be overly precise sometimes lol
Well there are many fake utility classes, because just because a method doesnβt require an instance doesnβt imply its a utility
what's an example of an immutable collection that lives a long time?
Most people who get started with Spigot development somehow think itβs a good idea to make everything as short as possible (at least in terms of naming variables). This is considered bad practice for a good reason. Whatβs the problem? Letβs imagine this is your code: In this example, it is obvious in line 4...
any
for instance VarHandle.loadLoadFence()
normally a collection does not suddenly die
bad OOP design then
(not that I wouldnt often do this myself, but I don't think it's good)
I'm also a chronic alcoholic, doesn't mean that I think drinking is good
You know i 1.8 when ppl created EnumSet<Material> as a way to tag materials
Well everything you write even in Java shouldnβt be 100% traditional oop comitted
but myeah presumably bad oop design
why not?
I like thinking in objects
Because java have introduced and is encouraging other paradigms
I like
oh yeah sure that exists but I never found a use case for that in like stuff like spigot plugins or desktop applications or similar
But the semantic style is there
I mean, it is pretty subjective how you use the language
aint nobody gonna use haskell to rewrite JDownloader lol
Havenβt seen much written in haskell when it comes to the actual industry
i mean there is a project here and there
the closest thing that is still barely acceptible to me as "stateful util class" is like the Bukkit class as the server itself is a singleton
I mean, you can literally go full functional in java
yeah it's handy but also pretty useless (the bukkit class)
Yeah lol
people could also be passing around the getServer() object but what's the point
Bukkit class is fine imho
I do that
I do that sometimes too
since that gives me mockability against Server :>
but mostly not lol
I still rely on MockBukkit for that sadly
I refuse to use PowerMocks or anything weird
MockBukkit is a mess and I hate it
Ah, I only rely on MockBukkit for certain things
I still use it because I don't wanna completely rewrite all my 2018 plugins
Trying to avoid pushing all my tests onto it
Like if a test is testable without emulating the server environment
Then heck yeah
in my newer stuff I tend to use so many modules that basically nothing depends on bukkit anymore besides an adapter class and a basic plugin loader
gradle is a curse and a blessing
Yeah right, so then you decoupled yourself enough to not having to rely on MB
Yeah
Gradle is nice but I hate it at the same time
I think this applies to every gradle user
Most definitely lol
worst choise they ever made was the toolchains forcing to use -release instead of -source and -target as compiler args
at least this applies if you do stuff like spigot plugins where you wanna support both 1.16 and 1.20
I think toolchains should at least give you the option to not be forced to use -release
Isnt sourceCompatibility and targetCompatibility a thing? Or was it that feature which got deprecated for removal?
sure but not if you use toolchains
Ah yea okay
if you set the toolchain to e.g. JavaVersion.of(17) then it sets -release to 17 and if you then try to set an additional source or targetCompat it says "no you cannot use this option together with -release"
Oh yeah thats true
that's why I refuse to use paperweight
yeah probably but I prefer to just use oldschool specialsource then instead
doesn't require any hacky workarounds
bad thing: it only gives you spigot-api
good thing: it does not force to use paper-api lol
in a perfect world, paper would just contribute upstream more but yeah I get it, people disagree with md bla bla and stuff
sorry I shouldnt have started this topic here lol
I know it's not a very popular discussion here lol
This sounds like a GriefPrevention problem to me
Gradle always breaks
okay
Ill finish my protein and then take a look at their "API" real quick
okay
finally
this is a dc bug
if u send a msg thats really long and then cluck on "make it a file" but you dont have perms to send files you cant see the file and cant remove it and cant every write in the channel again if u not verify and get perms
but back to my question
i get this error when reloading the plugin using plugmanX
?paste
Plugman π
Check your plugin.yml
Use getCommand and make sure it's in your plugin.yml
is there a way to get a plugins download version/link from the spigot api?
According to the documentation I don't think so, but there is https://spiget.org/
so when i debug like this:
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
e.getPlayer().sendMessage("Test works");
if(!MuteUtils.muteCheck(e.getPlayer())) {
e.getPlayer().sendMessage("is false");
}
if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
}```
And send a message it doesnt show "test works" in the chat
Did you register the event listener?
Thank youu
public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
e.getPlayer().sendMessage("Test works");
if(!MuteUtils.muteCheck(e.getPlayer())) {
e.getPlayer().sendMessage("is false");
}
if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
}
}```
you shoudl only do this if the event is not already cancelled e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
else you could be setting the cancelled state to false when another plugin has cancelled it
Hi guys. I've this scenario here.
Player gets Slow 1 effect for 1 minute -> Player gets Slow 2 effect for 20 seconds -> Slow 2 effect wears out -> Slow 1 effect is seen as active.
How do I remove 20 seconds Slow 2 effect instantly before it wears out on its own, without removing the existing Slow 1 effect?
Using removePotionEffect removed the potion effect altogether.
Guys I'm using smart Inventory API and I've come across a problem, when I put a list of items starting in the slot (1, 1) if I put fillBorders after setting the items, the items in the border will be above the items in my list and if I put it before, my items will be above the border, do you know how to solve this?
can u schedule sync from async or do i have to jump through hoops to get data back into the main thread
runTask schedules sync
You can schedule it on another thread
To be honest, after seeing two lines of their code i would have dropped it and just built on top of WorldGuard instead.
What diff?
from jefflib
Proper advancement API when?
so
Oh π but do you find the problem ? but otherwise I could use worldguard but I don't know api
they swapped one map for another
method changes
Does this mean that it uses the Bukkit methods to grant the advancement?
i think so
it adds it to the server through nms
@tender shard how does jefflib do toasts
That means I need a .json file to read from right?
this works of string json, but a file could work
That's fine. As long as I can actually send a toast, adding a file seems like a small price to pay.
I dont see a problem with their code. You might have some config value which limits claim sizes or you dont use the code you have shown us.
This sounds like an oversight on spigots side. I dont see a clear way of handling this without
some hacking because there is no api to handle the layered potion effects.
I tried that too but didnt succeed and then I got banned from paper lol
it injects a fake advancement into the advancement map
without creating any files
Sounds like you did something more than just keeping yourself out from it
Canβt believe you got banned just cause of that
doesn't work on 1.20.2 as the advancemap is now an immutablemap but that could be easily fixed by replacing it with a normal map in the static init block
Anyway this is not the channel for those kinds or discussions
who can help mee?
Why drawn pic now? What does he even do...
wait what? lol
This highly depends on what you are trying to do.
Is there a don't ask to ask command here
Sure
i need create uefi 64-bit bootloader, but i can't do this
you got given docs yesterday
What? What do you need that for? Do you even understand the UEFI specifications? They are huge
I thought of "what" too
ok..
read the docs you got given yesterday
here
here
nobody knows how?
Then just call fillBorders after setting the items. Isnt that what you need?
@trim elk
Replace it how? You mean in the ServerAdvancementManager via reflection?
so, but the items on the border will overlap the items I placed before
https://prnt.sc/u9wLOsblzPsJ I took a screenshot of how it looks
Hi everyone
I came across the problem that version 1.20.1 of NMS does not have the ClientBoundPlayerInfoPacket package...
Which package can I use instead of the outdated one?
@lost matrix
