#help-development
1 messages · Page 1243 of 1
how do you guys deal with situations where you have configurations/code which are identical in terms of functionality, so you decide to abstract them away under single helper function
but then you have to name it somehow that fits its functionality. in the end you get ridiculous name which might be too long..
WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player);
gameProfile = gameProfile.withName("GOAT : "+player.getName());
container.getPlayerInfoDataLists().write(1, List.of(
new PlayerInfoData(gameProfile, 0, EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()), WrappedChatComponent.fromText("GOAT : "+player.getName()))
));
this not work ;(
I mean, if it is an abstraction so should the name be
just name it something like SharedConfiguration or something
desktops := {
1: [
; Open all file explorer windows in first virtual desktop except for legacy control panel
{
process: "explorer.exe",
title: "^(?!Control Panel$).*$",
},
{
process: "WindowsTerminal.exe"
}
],
2: [
{
process: "Vesktop.exe",
action: (window, desktop) =>
MoveWindowToDesktop(window, desktop)
TryToMaximizeWindow(window)
SwitchToDesktop(desktop)
WinActivate(window)
}
],
3: [
{
process: "chrome.exe",
action: (window, desktop) =>
MoveWindowToDesktop(window, desktop)
TryToMaximizeWindow(window)
SwitchToDesktop(desktop)
WinActivate(window)
}
]
}
basically im making my own Autohotkey script where i can automatically position windows at specific virtual desktops. The problem as you can see, action for what to do in such case is repeating, i cant figure out what kind of name in this case should the function have. MoveActivateAndMaximizeWindowAndSwitchToDesktop?? that sounds so bad
my ahk script works just fine, but im thinking how to name things properly in such case where combinatorial explosion happen for specific use cases
(my question is language indepedent in a way, im just looking a suggestion how to deal with things like this, where combinatorial explosion makes silly names for helper code)
Move, activate and maximize
isn't that just focusing
just call it FocusWindow or something
thats very confusing because SetFocus() on windows focuses a keyboard input on window, not moves it to virtual desktop
by virtual desktop you mean a workspace
yes
?notworking
basically im providing suite of functions which you can plug-in to one singular action, and naming such things is kinda awful in a sense
"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.
Also if you're just trying to add prefixes use teams
pretty sure there's an api method to change the player's display name including the one over their heads as well
what about SetupWindowOnDesktop/SetupWindowOnWorkspace
In fact, the code changes the name everywhere except above the player's head.
Setup can imply many things so you can also expand that function if it becomes necessary
Not above the players head as far as I'm aware
I could, but then how could I change the nickname completely.
Was the player visible when you ran that code
If so despawn it and then respawn it again
See if that helps
i'm pretty sure i called it once and then everyone on the server had that over their heads, but maybe it's some interaction with TAB or something else that does it
okay
not work :/
kill other player, reload chunk ?
You need to stop the client from seeing the old name
If you just let them respawn the client will still know about the old name
I moved away and tried but without success. If I disconnect and reconnect it resets.
Remove the player from sight then send the remove player packet
is decapreced
It is not
Player::remove does not send a player remove packet
Also if you want to keep the username after relogging you need to capture packet being sent
or rename them after joining
https://github.com/iiAhmedYT/ModernDisguise/blob/master/VS-1_21_R3/src/main/java/dev/iiahmed/disguise/vs/VS1_21_R3.java look at how this dude does it with NMS, it should be more or less similar with protocollib
My IDE : he field EnumWrappers.PlayerInfoAction.REMOVE_PLAYER is deprecated
ah ok
im just going to probs name something like _CommonRuleAction(window, desktop)
welp it shouldnt be used outside of the config
famous last words
i hate naming things
english needs many bugfixes and patches
as buggy as cyberpunk 2077 at launch
I tried this but apart from making the player disappear from the tab it did nothing.
xD
public static void changePlayerNameTag(Main main, Player player) {
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO_REMOVE);
packet.getUUIDLists().write(0, Collections.singletonList(player.getUniqueId()));
for (Player player2 : main.getServer().getOnlinePlayers()) {
main.manager.sendServerPacket(player2, packet);
}
PacketContainer container = main.manager.createPacket(PacketType.Play.Server.PLAYER_INFO);
container.getPlayerInfoActions().write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME));
WrappedGameProfile gameProfile = new WrappedGameProfile(player.getUniqueId(), "test");
container.getPlayerInfoDataLists().write(1, List.of(
new PlayerInfoData(gameProfile, 0, EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()), WrappedChatComponent.fromText("test"))
));
for (Player player2 : main.getServer().getOnlinePlayers()) {
main.manager.sendServerPacket(player2, container);
}
}
oh
its work for nametag
But disappears from the tab 😂
you need to send another add packet with the listed action iirc
that's what the last packet sent already does.
It does not
I can't find any PLAYER_ADD packets
They meant the info packet
I did it!
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
this.main.db.addPlayer(e.getPlayer());
e.setJoinMessage(this.main.prefix+e.getPlayer().getName()+" a rejoins la partie.");
for ( Player onlinePlayers : Bukkit.getOnlinePlayers()) {
Utils.changePlayerNameTag(main, onlinePlayers);
}
}
public class Utils {
public static void changePlayerNameTag(Main main, Player player) {
player.setDisplayName("test");
player.setPlayerListName("test");
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO_REMOVE);
packet.getUUIDLists().write(0, Collections.singletonList(player.getUniqueId()));
for (Player player2 : main.getServer().getOnlinePlayers()) {
if(player != player2){
main.manager.sendServerPacket(player2, packet);
}
}
PacketContainer container = main.manager.createPacket(PacketType.Play.Server.PLAYER_INFO);
container.getPlayerInfoActions().write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME, EnumWrappers.PlayerInfoAction.UPDATE_LATENCY));
WrappedGameProfile gameProfile = new WrappedGameProfile(player.getUniqueId(), "test");
container.getPlayerInfoDataLists().write(1, List.of(
new PlayerInfoData(gameProfile, 0, EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()), WrappedChatComponent.fromText("test"))
));
for (Player player2 : main.getServer().getOnlinePlayers()) {
if(player != player2){
main.manager.sendServerPacket(player2, container);
}
}
}
}
However, this only works in the JoinPlayer event.
If not, don't see the player. Either way, he disappears from the tab.
why i can't do this? Player p = (Player) sender;
Inventory crafting = Bukkit.createInventory(p, InventoryType.CRAFTER);
p.openInventory(crafting);
why do you think you can't do that
the console says that when i use this command
you can't make the player open their own inventory
player inventory is client-side so it is just not possible from a plugin
i think the CRAFTER inventory refers to the new auto crafting block thing
what does it say
do not paraphrase errors
right, I was thinking of the crafting grid on the player inventory
this is the error https://paste.md-5.net/ediqacipum.bash
what are you trying to do, open an autocrafter inventory or the player's?
no the crafting the 3x3 one
you mean the workbench?
yes
the "Crafting Table"
btw the code is this
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
Player p = (Player) sender;
Inventory crafting = Bukkit.createInventory(p, InventoryType.CRAFTING);
p.openInventory(crafting);
return false;
}
then that's InventoryType.WORKBENCH, not CRAFTING
and what crafting does?
CRAFTING is the 2x2 crafting grid on the player's inventory
oh okay ty
though, you probably don't want to use create inventory for this, as the inventory will not work
the new API for it is MenuType.CRAFTING.create(player, "inventory title")
Isn’t the new api still being worked on?
it should work still
it's been merged for a while now
this part of the API, anyway
there was a part that was still not done, not sure what the state of that is
Yea, but I thought miles had like 3 more parts of it to complete?
yes
it is only really necessary when using packets and the such, anything else should be handled by the server already
how do i "update" the player's inventory then? i'm modifying items clientside for dynamic lore but if they switch to creative it messes it up since creative reflects clientside item changes to the server
changing items client side sounds very much like using packets
which is a valid scenario to use that method
ok
yeah because it is lmao
I mean, you could've been doing it with a client mod for all I know lol
is there a way for anvilprepareevent to work for shift clicking
are you in creative
i dont remember if i was creative when i tested it
lemme try again 1 sec
you're a genius
i love you
np lol
uncanny
if you are already doing packets why not just use custom enchantments
well, since the enchantment would actually exist on the server, you wouldn't have to manually handle applying to anvil or the such
then again, that means discarding what you've been doing up to now so it is up to you
intresting
here's a tutorial if you're interested: https://www.spigotmc.org/threads/1-21-3-register-custom-enchantments-with-nms.651347/
i'd only discard the anvil part, i would add a method in abstractenchant to register itself in bukkit
wait do i have to discard the lore part as well
well yeah since it'd actually be an enchantment and not an addition to the lore
it would just like Sharpness or the like would
ok
oh wait it's for 1.21+ only, i actually want it to be backwards compatible
i remember there was a way to register enchants before but it didn't add lore, but does it handle anvils and stuff?
how much backawards compatible
uh
because custom enchantments have been a thing since 1.20.4 I believe
yeah definatly before that even
well yeah then just continue doing what you were doing
ok
.
can i send an item change packet when they take the result out of the anvil
Hello, I am currently making a gun plugin and I want to create a reload feature and I need to detect the player pressing the key "R" in just plugin, and I am REALLY stuck here... Can somebody help me out? I don't care if the code uses nms
I am suddenly getting issues with my maven build processes, apparently to the point of running build tools being included. I am beyond confused how this pops up out of nowhere during a session of development. Anything pop to mind to anyone? At a total loss
You can’t detect key presses of keys that aren’t bound to an action
R is not bound to anything by default so you’re out of luck there, better use the swap hands hotkey or something
What does your pom look like and how are you building it
Need a little more detail. What errors are you getting?
Ok... thanks though
Im trying to do a custom anti xray but i cannot figure out what i am missing
please dm me if u know a fix
just explain your problem here
im trying to turn the javasource code to a .jar
Be honest with yourself, and us for a second, did chatGPT make the code?
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
why was kotlin
Hi guys! Quick question: is there a way to put the server status on Offline, even when it's online?
(I mean like offline in the server selection menu)
yes
Nice! How?
i think you can just set memory status as "offline"
I'm sorry, could you telle me where I can edit the memory status?
getConfig().set("memory.status", "offline");
wat
Wait im wrong 💀
i was looking at a plugin's source
im totally wrong sorry
i was looking at how this was spoofing
yeahh imma try it
& @kind hatch It was failing to get valid poms and erroring out on build. TBH I have no clue what the problem was. Something caching, but it was outside of ide and the .m2 folder / persiting through restarts because none of that was working yesterday. However some reason today it's all okay. Wonder if I ran too many builds and got timed out by one of my repos or something?
I swear sometimes if there's too stiff of a stiff breeze the magic smoke gets let out of maven and everything breaks 🤣
That’s why I switched to gradle
gradle is worse in terms of how much "magic" ends up being done
from your description, it could've been a hundred things really, so I couldn't say for sure but a repository being down is a pretty common issue, though it would've been clear from the error if that was the case
my guess is that it was more of an IDE issue than maven's, or at least in my experience, it's always been the IDE integration messing up the build system rather than the build system itself blowing up
Fair, at least for what my eyes get to see gradle seems prettier and easier to manage
sbt:
I despise gradles build config
makes no sense and feels like incantations combined with a programming language you had in a dream
Hi guys, i need help. Im trying run BuildTools for 1.16.5 to get nms. I got this error [WARNING] The requested profile "remapped" could not be activated because it does not exist. And its not creating remapped jars, what can i do?
so i cant use nms in previous versions?
You can
Just no mojang mappings for it (in Spigot)
Run BuildTools without the remapped flag and then depend on it like you would with the api but remove -api from the artifact
without classifier?
yes
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
and no special source needed
okay, now i understand, thank u
how do i make a player reel their fishing rod
i could be dumb but there isn't a single forum talking about that
actually there's one but idk if it's the best way, it says to use nms
Is there a way to set things like the font of an item's display name in Spigot
not in the api
How else would I do it?
nms
Is there a guide to setting up NMS on Spigot? I've only ever used it with Paper before
?nms
Does anyone know where I can download the official Minecraft Seven font that supports Unicode? The variants I found on the internet either don't support Unicode or only provide partial support for Unicode characters. The one Mojang is currently using is what I want (at least 1.20.6+), but I can't seem to find the font file anywhere in the .minecraft folder.
Minecraft uses GNU Unifont as a fallback when rendering a character a character it doesn't support
As for the Minecraft Seven or Mojangles you can find their texture(s) in assets\minecraft\textures\font
and you can find the font definition in assets/minecraft/font
idk if i'm getting mandela effect rn but i'm like 99% sure there was a way to make a player "use" an item with spigot api, is there actually one?
Thanks. So I need to somehow assemble the font from these assets?
Yes
Take a look at the font jsons it will show what character corresponds to each texture
hi, hope this is the right channel to ask about buildtools
Im trying to build 1 21 4 with java -jar BuildTools.jar --rev 1.21.4 --remapped remapped-mojang
but running into few exceptions - https://paste.denizenscript.com/View/131850
Ive already tried nuking folder, updating bt, checkin java ver etc etc
Could you try removing .m2\repository\org\spigotmc\minecraft-server\1.21.4-R0.1-SNAPSHOT
.m2 being in your user folder if you haven't moved it
why doesn't receiveClientPacket with USE_ITEM packet reel in the fishing rod but USE_ITEM_ON does? shouldn't they both reel the rod
protocollib btw forgot to mention
oh well guess you could try putting the csrg there manually
Also there's this which is concerning if you ran that in a clean folder
**** Warning, Minecraft jar hash of 17ea262a0dcdc35f285bd9ddf902cc26e8ab521911e1fe96c515a68165239e64 does not match stored hash of d7bbfba1a4ae1034d6b4f32e790d357c57cbace8c9120335a268cb647015e602
yea its all weird
oh and that log does not use the latest Buildtools
will try something out
Looks like I get that as well
Might not be important then 🤷♂️
nuked out whole m2 again, downloaded latest bt and here I am again with the same exception
Need you to run it in an empty folder
So I can see why it's failing at creating the csrg
alrigh
I wrote a python library ages ago to do this for you
It likely still works
It's not necessarily great and I am rewriting it
Patching Block.java
Exception in thread "main" java.lang.RuntimeException: Error patching Block.java
at org.spigotmc.builder.Builder.lambda$startBuilder$2(Builder.java:617)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Iterator.forEachRemaining(Unknown Source)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.forEach(Unknown Source)
at org.spigotmc.builder.Builder.startBuilder(Builder.java:568)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:60)
Caused by: difflib.PatchFailedException: Incorrect Chunk: the chunk content doesn't match the target
at difflib.Chunk.verify(Chunk.java:86)
at difflib.ChangeDelta.verify(ChangeDelta.java:78)
at difflib.ChangeDelta.applyTo(ChangeDelta.java:44)
at difflib.Patch.applyTo(Patch.java:43)
at difflib.DiffUtils.patch(DiffUtils.java:70)
at org.spigotmc.builder.Builder.lambda$startBuilder$2(Builder.java:605)
... 13 more
1.8 build error

that's not the point
Cleaning your work dir does nothing?
I forgot the name of the class something like groups, tags, damn
A Class with several lists where same blocks are grouped like wool, beds, doors etc
Can anyone help me? xd
Tag?
yea
no
yo
public static void create(Location location, String text) {
ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
armorStand.setCanPickupItems(false);
armorStand.setCustomName(text);
armorStand.setCustomNameVisible(true);
armorStand.setGravity(false);
armorStand.setVisible(false);
}
FloatingManage.create(new Location(Bukkit.getWorld("world"), -179, 141, -40), "§l§aFARM ZONE\n§r§fIci vous pouvez §3farm de l'xp §fpour obtenir le grade §eVIP §3gratuitement !");
In enable
but not working
please help me
I'm going to guess that your plugin is set to load before the world is
Also when spawning an entity that you plan on modifying use the spawn method that accepts a consumer
how can i see which plugin give me this datas? [20:37:10 WARN]: [org.bukkit.craftbukkit.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
how can i hide the template additional tooltip? (i tried it with the same method of the potion but it doesn't work :()
Looking for someone to help configure plug-ins on a new up-and-coming server called war of the world This will be a OpportunityTo gain experience in development and later on down the road maybe even a paid position on the server
About
This will be a leader based game mode where the objective is to either Be the top leader or dominate the rest of the world
There will be several different countries you can choose from when you start the game there will be guns cars Government and cops etc
The leader of your country will be able to make any laws or change current laws
it's an account created 2 days ago...
Yeah that's probably a bot
It should tell you
Example:
Legacy plugin Essentials v2.21.0-dev+185-5bf158c does not specify an api-version.
I removed the api-version from Essentials and it shows this ^^
oh okay ty and for the hide additional stuff of the template?
Try the different hide flags
the addItemFlags doesn't work
Are you testing on Paper
the server? (Purpur)
Enable debug in server config
?whereami
i'm using spigot for the plugin 🙂
i will change it asap
but there is a specific meta data for the Templates or there is a default way for hide the additional stuff from ItemMeta?
gg
HIDE_ADDITIONAL_TOOLTIP works fine
and how u put the HIDE_ADDITIONAL_TOOLTIP because the addItemFlags doens't work for me, i will try another time my intelij is a bit glitchy today
I used addItemFlags
okay i will try to restart
You probably forgot to reapply the item meta
i put the debug true and this is the message i get https://paste.md-5.net/bewuxabusi.md
Looks like you have your answer
ye it's a problem with the Tab papi and the Statistic placeholder but idk how to fix it or deal with it
You can just ignore it
Thanks bro! Appreciate it
Yoo does anyone know how to get to the anti cheat page
you mean on the wiki?
??
How do I download it
Download what
The anti cheat
there are many anticheats for the newest update
💀
welcome back darth mango
Thanks but I've never been gone
always in our hearts and whereami
I am always here and waiting for someone to summon me by using the magic spell
?whereami
I should code a plugin with that command that summons an NPC of me playing the whereami sound on a horn
hey
if you set display text to null and item lore to something... will display name still be there? like a blank text?
what if i dont want a display name and i just want a multi line text when i hover an item
does display name support multiline? should i just set the item lore and set display name to null??
man i feel so dumb as if im stuck at basics
how i can set the price of my plugin on spigot?
?faq
I'd just try and see, good way to learn
eh, was looking for a quick yes or no and why what response because then i dont have to go through all the crap with compiling and testing XD and i can smoke my cigarette to the end
doesnt testing that take about 30 seconds
less time than sending waiting for an answer xd
i have a lot of unfinished stuff laying around classes
oh
a lot of layers, PlayerTransaction -> PlayerTransactions -> PlayerWallet -> PlayerBank
Nuhuh
Null customname just reverts to the normal itemname btw, no multiline.
Lore can be more lines
can i have a lore without display name
Yes
Well
You can make it empty (or atleast a space if minecraft doesn’t like empty strings), not sure how good that looks tho
ok thanks!
I suck at regex, so maybe you could guys give me a hand to simplify this regex?
^(?:\\$|(?:\\[^\\\s]+)+)\\?$
this works at matching path separated strings
is there any way to simplify this?
^\\(?:[^\\\s]+\\)*[^\\\s]*$```
idk
Yeah the Clipboard class from AWT
why even use regex for this
doesn't seem to be trying to capture the strings in-between the path separator
wdym
i use it since im developing my own script which positions applications in virtual desktops based on regex window styles (or ex styles), classes, process names and window titles
desktops := {
1: [
; Open all file explorer windows in first virtual desktop except for legacy control panel
{
process: "explorer",
title: "^(?!Control Panel(?:\\[^\\]+)*$).*$",
class: "CabinetWClass"
},
...
open intellij and bam its already positioned for you at first virtual desktop
open chromium its in second virtual desktop
now i can switch between chromium by just using WIN + A, WIN + D
without having to manually position applications into virtual desktops as i do
declutters your desktop
by organizing apps automatically
basically backport of window rules from hyprland (linux) or glazewm(windows), but without automatic tiling (because windows apps are not designed for auto tiling)
eh, glazewm does a pretty good you at auto tiling
I just never understood the hype
like, opening apps and organizing them windows was never something that I felt the need to minmax lol, but I do know people love that kind of thing when done right
it's like setting up your vim config
idk it sucks, IDA pro for example just is plain awful to use with glaze wm
auto tiling is just not designed for win32 appplications
they look awful
ah, sub-windows are a pain point of glaze indeed
and buggy
I hated how it vertically aligned the file explorer dialog when downloading something
that's why i've created this script. i wanted to have glaze wm's window rules but without any tiling and just plainly use native windows virtual desktops instead of glazewm's fake ones so that things like snapping would work as usual
I eventually just configured glaze to ignore all the proper windows for automatic tiling
luckily I don't often use new programs so it wasn't as much of an issue
How can i make my own hidePlayer() but without the playerinforemovepacket part
by replicating that code with nms, but without the playerinforemovepacket part
i tried but i cant get some methods/variables

some stuff might be private for which you'll need to use reflection
any example?
You want to remake the hidePlayer() method... without the thing that hides the player...?
yes
??
but that... hides the player on client...
Are you trying to play Minecraft without the Minecraft client too, or what?
well you can apply invisibility potion effect
but that would make it prone to hack clients
I'm making a plugin that vanishes a region, but not with the effect. I want a vanish like that, at least that's what they asked me for, without removing them from the TAB or messing them up (because if I use the tab plugin and send a packet to add them, it gets messed up).
it was done like that in legacy versions of minecraft until it became obvious that hack clients exploited this
you can probably make an integration hook to a TAB plugin which adds an entry to the TAB list whenever player goes in vanish mode
basically a fake player entry
and when you go out of vanish you restore it back
I suggested that too but the client doesn't want that
current impl of vanish on spigot/paper sends player info remove packet just because it instructs client to remove player entity from the client's rendering as if the player disconnected from the server
its basically a hack to defend against hack clients
well if he disagrees, im afraid its impossible to do something like this without applying potion effect. I'll pass on this one, because im clueless of how would you implement such type of vanish on the server. Maybe im wrong, anyone else willing to discuss?
He told me that he had a plugin like that but in 1.16, that did something like that, made the hidePlayer and then sent the packet to add it to the tab, that it worked but the problem was the disorder of the tab list
you can probably fight with this by constructing fake player lists on player join by sending fake packets to the client about scoreboard teams or smth like that. That way you would have full control of the player lists any time. this sounds kinda difficult tho and would need research for this one
at this point i would probably edit the TAB plugin's source code to support something like this if it doesnt support it already
damn
minecraft client is just not designed for this. its not a game engine (although its coming closer and closer with each update and data driven datapacks)
maybe someday we would have proper support for that
But I've seen several servers that have this, I know it's possible
i guess maybe you can try to just remove the player from entity tracker
but i doubt that's enough
with mobs im guaranteed it would work for new chunk loads
but for player entities im not sure if the follow the same entity distance rules as mobs
Open a feature request to not remove from tab on JIRA tbh, seems reasonable
arent player entities handled differently
on client
or im clinging on old legacy version behaviour?
thank you
maybe, idk
would be kinda crazy if the only thing this code needs to support what you need is condition to check if player should be removed from tablist by sending remove player packet and boolean parameter passed to that method lol
Would also need a change to show method too but yeah for remove that's basically all it needs
maybe in such case it would be better to deprecate this method and propose such functionality to be moved into separate methods: Player#hidePlayerListEntry() / Player#showPlayerListEntry() and Player#hide() and Player#show() or smth like that
too bad there's no proper API dedicated to tab player lists on bukkit and everything is mushed into player interfaces
it would be neat to have PlayerList Interface which manages the player lists globally but allows to set player lists locally too
and in that interface it would be neat to move methods likePlayerList#add(Player) PlayerList#remove(Player), PlayerList#setHeader(string) (for setting it global, or move it under PlayerLists#setHeader(string) utility class since its just for loop for setting header for every player), PlayerList#setHeader(string, Player) PlayerList#setFooter(string) (for setting it global, or move it under PlayerList#setFooter(string) utility class since its just for loop for setting footer for every player), PlayerList#setFooter(string, player) methods
The problem is historically tab lists have depended on the player
If you remove a player from the tab list, the player broke
but that's not the case anymore rn as i can see if you can just remove the player entity from tracker and that's it?
public static boolean changeMapValue(TurboExpression.ChangeMode mode, Object value, Map<Object, Object> map) {
try {
if (mode == TurboExpression.ChangeMode.SET && value instanceof Map<?, ?> m) {
map.clear();
map.putAll(m);
}
} catch (ClassCastException ex) {
return false;
}```
is this safe
why are you catching a class cast exception there
idk what exception it throws
is that Skript related by any chance
no
well, it shouldn't throw any exceptions
if "m" has a different key or value than map it will 100% throw one
well, ideally that wouldn't ever happen
this whole piece of code smells like bad design somewhere
why are you passing around an Object instead of the proper type
if you are excepting any Map, then using Map<?, ?> as the type would do instead of just Object
public static <K, V> boolean changeMapValue(TurboExpression.ChangeMode mode, Object value, Map<K, V> map) {
try {
if (mode == TurboExpression.ChangeMode.SET && value instanceof Map<?, ?>) {
map.clear();
map.putAll((Map<K, V>) value);
}
} catch (ClassCastException ex) {
return false;
}```
something like this should also work i think
well no since Map<?, ?> isn't the same as Map<K, V>
can i just do something similar to if (value instance of Map<K, V>) because it doesn't let me
that's what the catch is for
my question is why is the parameter type Object instead of Map<?, ?>
because then it yells at me if i try adding a random map with a random key and value type to it
and if value and map are supposed to share a key, you could do:
public static <K, V> boolean changeMapValue(TurboExpression.ChangeMode mode, Map<K, V> value, Map<K, V> map) {
if (mode == TurboExpression.ChangeMode.SET) {
map.clear();
map.putAll(value);
}
}
then pass the class as a parameter too
i just want to return false if
- value isn't a map and mode is set
- value is a map and mode is set but value doesn't share the same key or value with map
class of what, sorry if im dumb
what is that name of the problem im having
ima search it up
make Object type as V
that way it would infer the value parameter of the map for the value parameter
it's called value but it's not the value of the map
... V value, Map<K, V> map
the "value" could literally be a whole other map to change the original map
so it can't be V
it is just not a design I'd want to deal with tbh, there's no compile-time safety
your initial code should work as is
this one?
yes
k
im not sure if this will work but maybe Object value, Map<K, ? super V>?
i dont have ide right now and generics for me is confusing to comprehend without its support lol
i don't think it'll work
i'll just stick with the original one as javier said
if i run into issues later on i'll try looking into it
also if i change item.getEnchantments() does it reflect on the item
I would assume no since there are add and remove methods but, try it just to be sure
Map<?,?> is somewhat diabolical icl though
use typed instructions
Hi, Is there any way to influence Math.random on the server from the client?
no.
bro is trying to cheat on a roulette server clearly 😭
RNG is Timestamp-Dependent.
lol
I meaaaann
There have been ways to influence enchanting in such a way where you had guaranteed enchants after you do certain actions
It involved casting fishing rod, getting the UUID from it and somehow getting the random seed based on that :D
You have way better channces at predicting RNG out of the 2^48 iterations, than manipulating or influecning it
yes but also a plugin could just have its own Random instance with a different seed or whatever
no i have simple totalizator plugin and players often tell me that there are some players who always win, so i am trying to find is there is possible)
@sharp crest look into Apophenia (Illusory Pattern Perception)
man me and the boys used to tell eachother "if you hit a chest with your pickaxe 3 times before opening it, you'll get good loot" in fortnite.
its nothing more than your braining looking for patterns.
aka they just have good luck
Yeah
unless you messed up your plugin ig
like resetting the rando with the same seed every time or something
lmfao yeah good point, @sharp crest drop your code.
ok, but later
ok
you mean always using the same new Random()?
well with the same seed specifically
are you doing this?
long seed = 12345L;
Random rng = new Random(seed);
passing anything to Random
looks like this
Game.this.winner = (Player) Game.this.players.stream().skip(
(long)ThreadLocalRandom.current().nextInt(Game.this.players.size())
).findAny().orElse((Object)null);
technically predictable, but idek
you'd have to be like insanely good at pattern recognition, like beyond that of professional card counterrs
yeah they are just lucky it seems
when setting probability did you set 80 instead of 0.8 or smt
There is no pattern here though
It depends on player count so that’s a very small variance anyway, they must play enough to beat the odds
🤔
classNotFoundException for postgresql. Driver session builder class factory -> https://paste.md-5.net/cohohaqofo.cpp
hey
can PDC slow down the world loading process?
if i have eg.: 20k blocks with PDC, to detect which ones were manually placed
Well the PDC has to be read from disk, so I guess it would
soo if i have a really good disk, m.2 ssd with speeds up to 7000mb/s read and write
What would the structure of this be ?
would it have any effect
just a simple manuallyPlaced key with some value
value like .. true
doesn't really matter, as long as it contains a key
value does not matter
i'd have to check for the key on BlockBreakEvent so for each block that is broken
I feel like you could optimize that a bit
If that's a real thing you made not just thing for sake of example
My approach would be: per chunk have a PDC. That would contain lists of shorts which will be keyed with the y of the subchunk
you can calculate the index from the block pos in subchunk
Might wanna use ShortSet from FastUtil (I believe that should exist) for ultimate speed :D
But I feel like these are all premature microoptimizations...
Both should help with what you're doing
You'd be storing less data -> world loads faster
and the lookup should be faster like this (? not sure about this one)
all I need this for is, i'll give n amount of xp to the player each time they break a block and to prevent abusing I need PDC
Can someone make me a macro for Mac ? I’ll pay
?services & no clue what you're asking for
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
I suppose for some simple like that you can ask gpt
Mhmm
Also you could use a bitmask
Make a threshold for blocks broken per subchunk and switch to bitmask
Again, still doing microoptimizations and complicating the implementation unnecessarily :D
I just downloaded a plugin that doesnt work
why do i see stuff like these even tho i imported the repo?
you are better off creating a custom binary file and making use of memory mapping for this
I have said in the past how efficient this is
pdc will never match it
a custom binary file ...
then the binary file could reach megabytes in size and io operations could also take long
custom in the sense choosing which character to use for separations etc
not with memory mapping
with java 1.7 and using this method, you can load 10-15 million blocks in 6 seconds and save it in 3
might have been 20 million, either way it was a lot
we didn't really test the limits of how much before it slowed down, just that it was sufficient amount
what if player breaks like 20 blocks in 1 second with a pickaxe with enchantments
for each block i need to check if its been manually placed or not
in 600ms
20 blocks is not 15 million
loading 15 million blocks and accessing a data structure that holds those blocks is completely different
but 15million blocks have been manually placed and I need to find if any of these 20 blocks match in the binary file
while true, the plugin that was designed is exactly what spexx here is making
it was for storing data on blocks placed from players that were in creative so that those in survival could not obtain them if they broke
yet currently to date nothing beats it
but think what you want, should probably try it before casting doubt
I mean,honestly the biggest issue is gonna be read/finding the blocks
loading IO is pretty damn irrelevant when most chunk loading is async anyway
memory mapping loads the entire or parts of the file directly into memory, not going to get faster then reading from memory
finding
so I would need more memory also, for this
only an issue if you load only parts of the file and not the whole thing
how so. If I load in a section of bytes from a file into memory, I still need an algorithm to find me specific blocks
depends how many blocks you need to store, but yes and no. You don't have to load the entire file. 15 million blocks of data was like 1-2gb of ram
because you load the data instead of manipulating raw
"load the data"
look I am not going to argue
yea "load the data" its going to take long
no
yes
ok fine then be stuck with your doubt 🙂
for each block that is broken, i need to load the data
currently nothing beats this method
in your case a binary file
I just think that the part of "imma do a normal read" vs "i'll directly map a files content into memory" is not as important as the "I need to find a datastructure that properly supports finding block x y and z in a near infinite world"
its not hard
you are just saying it is
we don't live in a time where we are discovering how to do this stuff
its already been done
Well but doing so on the raw mapped memory is annoying
unless you read it all into a proper datastructure
which you should because why wouldn't you if you loaded it into memory?
reading from memory is a whole hell lot faster then any ssd or hdd
same with writing
what
the OS takes care of writing back to ssd
The algorithm to correctly organise your giant buffer of a memory mapped file certainly is not "easy"
at least to do it (semi)optimally
its been done
its not new
"it's been done", I mean, throw it here
I'd be shocked if there is an actual consensus on anything regarding that kinda of layout
you don't need a consensus
you don't even need the most efficient
they don't have a server of 1k+ players
so what efficiency are we needing?
it just needs to be efficient enough
how would you structure the binary file to make lookups as fast as possible? wouldnt indexing be necessary? id still have to scan large portions of the file every time a block is broken
its binary data, so its based around control characters to separate the data
just know reading from a memory mapped file you are not limited to reading or writing in one direction
you can read forward or backwards
same with writing technically too
can you show me some samples "it's been done"
if a binary file is large, you can create multiple MappedByteBuffer of different regions of the same file
and interact and do stuff with those regions independently of one another
Guys please make me a Makro for Mac Minecraft I’ll pay
just go learn it yourself
google some youtube video and stop bugging people
also
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
AHK my beloved
I don't have any samples on hand or should say readily available. Since you are not familiar with memory mapping this seems like an opportunity to mess with something new
you are not going to get anything faster then memory. Not even ssd's come close to it
the reason the file needs to be binary is because before a file can be loaded into memory it has to be translated to binary first
if its already binary, it just saves the OS a step
Heya, I'm currently programming for a streamer on Twitch, and he wants to have a game mode where he and the viewers can play along. In the game mode, many things are saved such as teams, points, players, timers, etc.
Does it make sense to use Redis for this, or are normal lists/hash maps also sufficient?
It seems unnecessary unless you want to have multiple servers that are synced
If you want to save wins and total points, you should write them to a DB at the end of the game
fortcode is beautiful, keep doing you!
what is fortcode
what's a backwards compatible way of getting the entity killer in a PlayerDeathEvent?
Is Anyone good in Keyboard Maestro Mac ?
Someone probably is
Get the attacker in the EntityDamageByEntityEvent
Sure that works
k
why does a java 21-compiled plugin throw an unsupported major file version 65 error even when started with hava 21?
using server version 1.19.4
That's an old ASM version
You should be using Java 17 for 1.19.4
Ah the pain of old java versions
how to change player's health after the event not before,
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
if (player.isOnline() && !player.isDead()) {
player.setHealth(newHealth);
}
}, 1L);
like this?
That would delay it by 1 tick I believe
Which event?
thats entitydamageentity
I mean it should work but if you are using newHealth to set damage to the player it wont account for armor or effects hard to tell what you are trying to do from the snippet
?tas
yeah thats not the important thing
Can someone help me with intrinsics of the StructureManager? I am probably missing something trivial here:
Recently I tried the following snippet, just for the purposes of replicating the functionality of the /place -command, but just in the plugin code. The following snippet is from the forums: https://www.spigotmc.org/threads/generate-a-structure.643122/
NamespacedKey structureKey = NamespacedKey.minecraft("mineshaft");
Structure structure = Bukkit.getStructureManager().getStructure(structureKey);
if (structure == null) {
structure = Bukkit.getStructureManager().loadStructure(structureKey); // Try and load it if it isn't already
if (structure == null) {
plugin.getLogger().info("Structure is still null");
return false; // The structure doesn't exist
}
}
And it logs the "Structure is still null".
Now the problem is that no matter what I've tried the loadStructure -call always returns a null. I tried to check other keys from minecraft wiki but at least all of these did not seem to work:
NamespacedKey.minecraft("bastion_remnant"),
NamespacedKey.minecraft("ancient_city"),
NamespacedKey.minecraft("buried_treasure"),
NamespacedKey.minecraft("desert_pyramid"),
NamespacedKey.minecraft("stronghold"),
NamespacedKey.minecraft("shipwreck")
So can someone enlighten me how should this be used? Thank you!
but is it a good solution
runTaskLater is a good solution if you want to be able to adjust the amount of ticks before it runs
should run synchronously
.runTask would run immediatly after the event so you can't really mess with a delay
okay so just runtask
guys what type of method should i use if i want that a player isnt allowed to edit a sign?
declaration: package: org.bukkit.event.block, class: SignChangeEvent
If a Sign Change event is cancelled, the sign will not be changed.
can you display dynamic textures with a resource pack?
Depends on what you mean by dynamic
changes based on context
There's some texture A for entity
switch it to B
without redownloading anything
You can swap the model of the item
where B is dynamically generated
it's also for a 3d model
Not enough information to say if that's possible
Okay, let me just retract my statement and say exactly what I need
you can piece it together if you have a texture for every individual pixel, for each individual colour, but please don't
I uh-
am doing that
exactly
yeah, please just don't
this is 5000 text displays
Then you just core shader a skull?
since that already has access to the full player skin texture
hmm so with core shaders it's possible?
I see, how hard is that to impl?
How good are you at math
cuz well
I made this guessing
so uh
not at high level
but good at current level
I really really wouldn't recommend you spawn thousands of entities which actually render
it's all spoofed its aighttt
why not just do this
that's not the point
also its surprisingly lightweight
the client will just die on worse PCs
I can have 10 of these no problem
only goes from 300 to 40 fps when 10 are in place
it's fineee
no problem
260 fps less
not too shabby
what math level are we talking
You'll be doing some shader programming
never done that
so linear algebra
what's this?
A repo full of core shaders
a repo full of shaders to copy code from
JNNGL makes some really cool ones
waiting for him to update quite a few of them
I use GUI Avatars and it's really easy to setup
so sending like 800 updates every two ticks isn't ideal?
huh, I guess you learn something new every day
can we somehow batch those maybe?
what did I lie about
pls explain how this is linear algebra
and where do all of these magic values come from
If you've never worked with it I recommend this playlist: https://www.youtube.com/watch?v=fNk_zzaMoSs&list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab
Beginning the linear algebra series with the basics.
Help fund future projects: https://www.patreon.com/3blue1brown
Music: https://vincerubinetti.bandcamp.com/track/grants-etude
Thanks to Elo Marie Viennot and Ambros Gleixner from HTW Berlin (www.htw-berlin.de) for contributing German translations and dubbing.
Thanks also to these viewers for...
3b1b my beloved
how can i store all the inventory items of someone in an hashmap and give it back_
use InventoryRollbackplus plugin
you see, you can't always integrate 3rd party plugins into your code
i know this plugin i don't want to use it because i need a small stuff of it just to make different inventory for different worlds 🙂
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Inventory.html
Working with Inventory#getContent and Inventory#setContent could be a start?
it's something like an hashmap with ItemStack[] to store the inventory#getContent and after i give the stored back with the setContent?
Where do I make a commission?
I dont know what you mean with that.
oh okay i will just try ty anyways 🙂
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
The most of the part is reading and trying. The "right" way is only "Is it working". You can follow best practice and follow documentation but there will never be a documentation for anything you want. And btw Bukkit/Spigot didnt start because of "The Right Way". Minecraft dont support plugins at all. Some just "Make it".
ty 🙂
how do you enable word wrap in yml in intellij idea
there is no proper setting like "enable word-wrap" A SIMPLE ENABLE/DISABLE
how do i make a commission there?
what the heck is soft wrap and hard wrap. give me a setting, a boolean setting, true /false, yes or no. what the shit
whoever designed the yaml settings is a total dumbass
and nothing works
anyone know if I have a published plugin and update it with external download as a GitHub release, and I have another addon that adapts my plugin with another one, can I publish it in the same GitHub release? Or do I need to create a new resource on Spigot for this?
Hard wrapping is like physically writing new lines of text. A new line is placed between each line. Soft wrapping is just visual in the editor
You probably want soft wrapping
i miss Eclipse
XD
i think i was more productive there
i turned on soft wrap but nothing changed, not in yaml or java files
Then it's brokey
That's the exact reason I stayed on Eclipse after trying IJ
IJ is nice but it is silly at times
Hii does anyone know how to get the info that a sponge has turned into a wet sponge? I use blockphysicsevent with getChangedType == Sponge and check after it if the Sponge has Water around it. But i think there is a more direct way to see the change of the sponge turning to a wet sponge. I also think about checking the blockstate but im not sure if that would work out. Before wasting my time with that last piece i thought i may ask some pros :3 or i may just leave it like so idk
maybe this event could help you? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/SpongeAbsorbEvent.html
declaration: package: org.bukkit.event.block, class: SpongeAbsorbEvent
Oh wow thank you that is excatly the one i needed but i couldnt find it anywhere 🙏🙏
its kinda burried by the fact that so many people asked for this. and your solution was the answer in most places haha
Haha funny xd
Hoi ppl
^ ToggleCommand
so im making a toggle command for a GriefNotifier plugin
it sends a message to all OP's whenever someone breaks a block
^ BreakBlockListener
How could i make a toggle command where i can toggle off teh receiving of those messages?
You already have a toggle command
You just need to check if they have it toggled on before sending the message
also use a Set of uuids instead of an array list of strings
sure
and running both contains and remove is redundant
Just run remove and check it's return value
wdym
The remove method returns boolean that shows if something was removed or not
ok i removed the toggled.add()
Wait why
u said just run remove
and running both contains and remove is redundant
Just run remove and check it's return value
I was just talking about contains and remove
I said nothing about add
how can i check it
there is already return true;
I wait I didn't see which message you replied to
You call contains to check if it's in a Set/List
yes but how do i turn off the messages ent
by not sending one
The messages will be off when the player isn't in the list
since you check if they're in the list before sending one
yes but they in different java classes
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
they are not connected actually
Connect them
Olivo i already know java
You do not
I do
if you have no idea how to access something from another class
then I would not say you know Java
bruh, duh using this.plugin = plugin
lol
You didn't know java last year when you were here and still don't know it properly now, learning java helps a lot when making plugins
does setCollidable not work?
people learn
they dont remain where u left them
Well, you seemingly aren't learning Java
If you don't know how to access classes and just say "this.plugin = plugin" I don't think you know java
Did you read the cons of using that method in the javadoc
Thats how u do it
literally
What else do you do
wdym?
the listener will access the state of the toggle property to determine whether to send messages or not, and the command will write that property based on player input
there are a number of ways to go about this
Just adding plugin doesn't give you acess to everything
You have another step to do
I would need now to disable the messages, checking if a player is already in the Set is already done
so access the set from the listener to disable/enable the messages, yes?
yus
so instead of doing this.plugin = plugin you'd presumably do something with the set rather than the plugin itself?
wdym?
like what?
can you explain what this.plugin = plugin does
Note that the client may predict the collision between itself and another entity, resulting in this flag not working for player collisions. This method should therefore only be used to set the collision status of non-player entities.
To control player collisions, use Team.Option.COLLISION_RULE in combination with a Scoreboard and a Team.
no wrong answers here, just try writing down what it is that it does
we arent here to test my java knowledge?
but sure, it lets u connect the classes, so for example if u used a hashmap in a class, u can recall it in another class by placing plugin. in front
i'm not here to spoonfeed you either
i didnt ask u to?
so i need to know where we are starting from to get you to where you need to be
Im trying to understand the logic behinf it
and your current understanding of the topic is where we are starting from
I dont understand the point to reproach lack of java knowledge if someone needs help
i could give you the code to do it word for word, but i'd rather teach you to fish
and to do that i need to know where you are right now
in your example here you noted a hashmap in another class, and your problem is fundamentally the same; you have a hashset in another class that you need to access
can you describe your problem
But u guys are more worried about my java knowledge then the actual issue im facing
and what is that issue
from what i understood your problem is figuring out how to stop sending messages to a specific player
is this not the issue?
right
so bear with me here
you have a set of player names to whom you do not want to send the messages, yes?
or rather the converse, that is, a set of player names to whom you want to send the messages
based on the command feedback in your command class yes
now, the actual message sending is done in the block break listener
as soon as I added Vault to the project now I can't use that?
supposing you had access to the set there, you could do
if (toggled.contains(player.getName())) player.sendMessage(...);
but the toggled set is in another class
paper, and make sure vault is 1.7.1
Exclude the bukkit dep that comes with Vault
Also yeah that's Paper API
so... we cycle back to this
iirc vault 1.7.1 might have fixed smth about it
in conclusion you have a hashset in the command class that you need to access from the listener class, yes?
I think so
and this is quite similar to your example of accessing a hashmap from another class, right
ok thx
so now that we've agreed that they are quite similar, let's take a look at the differences
?
the biggest difference is that in your example, the hashmap is in the plugin class; right now, the toggled hashset is in the command class
so rather than passing the plugin to your listener class, you'd want to pass the command to your listener class, since that's where the set is
how might we go about doing this?
getting warmer
wdym?
let's see your main plugin class
paper !!!
NOoooo
'bout to get whereami'd
let's start with what is already familiar; try passing your plugin to the listener with the this.plugin = plugin bit
good, and let's also see the updated plugin class
getServer().getPluginManager().registerEvents(new BlockBreakEventListener(this), this);```
right
now this is something of a tangential issue, but the way you're setting your command executor isn't right; currently you are setting this as the executor for that command, not your command class
what you want to do is construct your command class with new and then pass that to setExecutor instead of this
very much like you do with your listener class, which you pass to registerEvents
getCommand("togglealert").setExecutor(new ToggleCommand());```
good
now, going back to when we talked about the differences between your example and the current problem, let's remember that rather than your plugin, your listener class needs your command class
so instead of passing your plugin to it, you should pass the command
so change the this.plugin = plugin bit to this.listener = listener and change the field and constructor parameter types from GriefNotifier to ToggleCommand
ToggleCommand listener;
public BlockBreakEventListener(ToggleCommand listener) {
this.listener = listener;
}```
good
and now, in your plugin class, you should be seeing an error
because now to construct your BlockBreakEventListener class, it needs a ToggleCommand passed to it
there are two ways in which you can fix this error, one of them is wrong and the other is right
try fiddling with it to fix the error and then we'll take a look at your main plugin class again
wait
where should i place this
in the listener class right?
yes, that is the constructor of the listener class now
replaces this
GriefNotifier plugin;
public BlockBreakEventListener(GriefNotifier plugin) {
this.plugin = plugin;
}
remove that; like i said, just change the types, don't add a new constructor
ok done
and yes an error
getServer().getPluginManager().registerEvents(new BlockBreakEventListener(new ToggleCommand()), this);```
right
this is one of the two ways to fix the error
the wrong way
let's see your onEnable in full
this is wrong yes
but it's progress, still
let's see your onEnable method in full and I'll explain why and how to make it right
@Override
public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvents(new BlockBreakEventListener(new ToggleCommand()), this);
getCommand("togglealert").setExecutor(new ToggleCommand());
}
so here we see new ToggleCommand() twice
this means that you are actually creating two commands
you are creating one and passing it to the listener
and then you are creating another and registering it as a command
the problem with this is that now there are two toggle commands, there are also two toggled lists; one for each command
so what we want to do is only call new ToggleCommand() once but pass that to both the listener and the setExecutor
any ideas how to do that?
no
what we need here is a way to hold on to a value for more than just a single expression
this would be achieved with a variable
let's take a look at your listener class
public void onBlockBreak(BlockBreakEvent event) {
Player breaker = event.getPlayer();
Block block = event.getBlock();
Location blockCoordinates = block.getLocation();
long X = blockCoordinates.getBlockX();
long Y = blockCoordinates.getBlockY();
long Z = blockCoordinates.getBlockZ();
broadcastMessageToOPs(breaker.getName() + " broke " + block.getBlockData().getMaterial() + " at x" + X + " y" + Y + " z" + Z);
}
notice how we are calling block.getLocation() once but using the result thrice; to get its X, Y and Z coordinate
this is because we assign the value to the blockCoordinates variable