#help-development
1 messages · Page 299 of 1
Yo, is it normal that in creative mod i can manage to glitch and take the items in guis where i set setcancelled true on inventoryClickEvent, but not in survivalmode?
creative mode is client side
Yeah working with Creative mode is a mess since the client has control
it didn't work, I somehow have to check if the block from location list has been blow up and cancel the event
Hi
I'm learing the write plugin but it gives this error
[11:20:12 ERROR]: Could not load 'plugins/selamla.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:154) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.loadPlugins(CraftServer.java:419) ~[purpur-1.19.jar:git-Purpur-1670]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:313) ~[purpur-1.19.jar:git-Purpur-1670]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1137) ~[purpur-1.19.jar:git-Purpur-1670]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:307) ~[purpur-1.19.jar:git-Purpur-1670]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
ntm#1234 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:170) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.loadPlugins(CraftServer.java:412) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3553-Spigot-14a2382-ef09464]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:224) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3553-Spigot-14a2382-ef09464]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:966) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3553-Spigot-14a2382-ef09464]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3553-Spigot-14a2382-ef09464]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
It gives this error
My JAR file has a plugin.yml
name: Selamla
main: org.selamla.Main
version: 1.0.0
it should be in the resources
[11:44:18] [Server thread/ERROR]: [Selamla] Selamla v1.0.0 attempted to register an invalid EventHandler method signature "public void org.selamla.Main.karsilama(org.bukkit.event.player.PlayerJoinEvent,java.lang.String[])" in class org.selamla.Main
package org.selamla;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener{
public void onEnable() {
getLogger().info("Eklenti başladı.");
Bukkit.getPluginManager().registerEvents(this, this);
}
public void onDisable() {
getLogger().info("Eklenti devre dışı bırakıldı.");
}
@EventHandler
public void karsilama(PlayerJoinEvent event,String args[]) {
Player oyuncu = event.getPlayer();
oyuncu.sendMessage(ChatColor.GREEN + "%s adlı oyuncu sunucuya katıldı !",oyuncu.getName());
}
}
Can I use %s without String args[]
%s joined the server
Like this
@EventHandler
public void karsilama(PlayerJoinEvent event) {
Player oyuncu = event.getPlayer();
oyuncu.sendMessage(ChatColor.GREEN + oyuncu.getName() + " adlı oyuncu sunucuya katıldı !");
}
}
Is it work ?
Thanks for everything
I'm new in plugin codding
Can I compile code without a Eclipse ?
I'm writing codes with VSCode
When I was the compile I'm opening Eclipse IDE
Can I compile in VSCode
IntelliJ IDEA is very heavy ide
For my computer
How can i compile in terminal
I'm pretty sure vscode is heavier and much more unstable
Block from the location list still get destroyed, I tried different if statements versions and still same result.
When I run the line of code MinecraftServer server = craftPlayer.getHandle().getServer() in the form of a command, the console responds with java.lang.NoSuchMethodError: 'net.minecraft.server.level.ServerPlayer org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer.getHandle() I have installed mojang mappings and have the right pom.xml dependencies and plugins. Am I not doing something right?
How can I create Ghost Items?
Or just prevent dupe glitch.
I save all content of GUI into PDC
But after save, players can just take those items and get easy Dupe
why is your lore method taking in a list of strings and not just varargs and why is it mutable?
wait wtf
yes, i have the plugin net.md-5 v1.2.4, is that what you are referring to?
@EventHandler
public void onClick(final InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getCurrentItem() == null) {
return;
}
ItemStack item = e.getCurrentItem();
if (NBTUtils.contains(item, "ticket_inv")) {
if (e.getClickedInventory().equals(p.getInventory())) {
if (e.getRawSlot() == 40 || e.getRawSlot() == 41) {
e.setCancelled(true);
p.sendMessage(Utils.colorize("&cYou cannot place the ticket in your offhand or crafting slots."));
return;
}
} else {
e.setCancelled(true);
p.sendMessage(Utils.colorize("&cYou cannot move the ticket to this inventory."));
}
}
}
Someone knows why i can still put it in my offhand from my inventory?
And why i can place it in the crafting slot but not take it out?
This code is for 1.12.2 and it should make it so that you cant put the item in offhand or crafting slots
its maybe an inv move event?
didnt see the split part
dunno what mess that is
i hope youre not setting the item meta on every method
well you should only do it at the build method
its not just a setter
that the impl of ItemStack#setItemMeta, i personally wouldnt call that every time
is there a way to get the slot number in an inventory?
Regex
@EventHandler
public void onPlayerInvClick(InventoryClickEvent event){
MenuGui menuGui = new MenuGui(null);
Inventory playerInventory = event.getInventory();
switch(event.getCurrentItem().get) {
case
}
yea
I dont have that option?
i have 9 slots
in my gui
i want to set a switch that based on the slot of the item does something
what is that #
because the lists are not the same
you are checking equals on 2 lists
Thanks, although again, plugging in the dependencies and plugins into Maven still does not work. Should I do it manually?
I fixed it using blockList thx
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Is there a specific location that it exports the remapped jar files to? I just set the artifacts for intellij to a specific folder and it just creates one file
Ah yeah it's not creating any remapped jar files, the target folder doesn't have any jars
Happy to hear that you found a solution! It very much seems like the double-hit when critically damaging is intended for that version, so it would have been very hard to do anything against that. Anyways, you didn't give up and managed to analyze the situation to a point where you could come up with such a creative solution nobody even thought about before, which is what true problem solving is all about: solving the unsolvable. I'm proud to see that there are still people around who have these traits! :)
when was teams character limit removed spigoteers?
so i just remembered about forge workspaces for mods and was wondering if theres anything like that for a server jar? all classes included. im guessing not cus legal bs but just wondering. a google search pulled up a bunch of forge stuff
Yep, same error
Maybe it's something to do with my intellij?
Yes
java -jar BuildTools.jar --rev 1.19.3 --remapped
The remapped mojang jars?
So yea I have all the remapped jars in BuildTools\Spigot\Spigot-Server\target
But not the remapped project jars
Fairly certain it installa them to local maven too
I think so, lemme check
Ok I found the remapped 1.19.3 jars in m2\repository\org\spigotmc\spigot\1.19.3-R0.1-SNAPSHOT
Ok thx I will watch
Location location = ("world",4,3,5); why is that wrong?
new Location
With new Location you create a new Location-Object, where ("world",4,3,5) would instantly error
I think I see the problem. At around 1:00:18 - 1:00:33 in the video. If you look at the top right, he has a configuration called "understanding-nms-build". He refreshes the pom.xml and then runs the configuration. The thing is, I never created a configuration. When I create a maven configuration it asks me for a command line to run. Do you know what this command might be?
/alert <your message>
How can i use in plugin
Bukkit.broadcastMessage("helo boi");
anyone knows if loading guava cache values asynchronously is safe?
like
CompletableFuture.runAsync(() -> cache.refresh(locale));
// or
CompletableFuture.runAsync(() -> cache.getUnchecked(locale));
whats that class?
?
whats the class of cache?
idk i just do CacheBuilder.newBuilder().build(new LanguageCacheLoader())
k thanks i wasn't very careful while reading the docs
should be something like
ProxyServer#broadcast
how to get overworld world?
Where is the site for viewing mojang mappings?
Bukkit.getWorlds().get(0)
0 is overworld, 1 is nether, 2 is end and all others are custom worlds
Hey, i create a custom world with a custom ChunkGenerator. My generateNoise function looks like this: ```java
@Override
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull ChunkData chunkData) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
if (x == 0 && z == 0) {
continue;
}
chunkData.setRegion(x, chunkData.getMinHeight(), z, x + 1, chunkData.getMaxHeight(), z + 1, Material.AIR);
}
}
}
nice, ty
I'm making an API for myself that supports multiple databases for one project. Database APIs tend to be fairly bulky is there a decent way to provide support for all these databases without racking up my jar size to like 100mbs from shading
sqlite is already included in the server so you dont need to shade that one
the libraries section in the plugin.yml is a thing too
more thinking like MySQL, Mongo etc which aren't provided by spigot
im wondering if you can load those jars on the go, like the plugin system does
libraries section is a fine idea, but my API isn't a plugin. I could turn it into one though I suppose
ik it changed for me
oh i thought that was a linux font issue
i dont like it
what about other langs
#pragma once
void init();
int read(const char*);
struct test {
int a;
};```
let: str = "Yeah they definitely did"
let var: str = "Variable"
var str: string := "Go Lang"
looks so eh
bleh
i wouldnt be surprised if they will charge money for using discord in the future
How to delete all players inventory in my world [lobby] multiverse core
maybe they are depending on it?
i suppose I just wanted to give programmer talk so they run away crying
Anyone know how I can get started with making custom biomes using mojangs mappings?
It's already thing if you are from America afaik
It's like buying ranks trough discord
I'm going to bump because I'm still not sure what would be the right thing to do here
I want to make my own biomes so I can change the colour of the sky for example
Well you can probably load classes via reflection same way newer version of spigot do, altrough I'm not sure how, iirc Alex was writing about it few days ago, so you can probably search it up
I mean ideally I'd somehow download them to spigots library folder, but since my API isn't a plugin that is stumping me
hi im using worldguard and worldedit plugin but i don't know how to convert a bukkit.world into a worldedit.World does anyone have a clue?
It is possible
This is just the 1.17 version and not using mappings
Ty
Involves selling your personal info though
dedicatedserver.getCustomRegistry() doesn't exist in the mappings
Idk what i'm meant to use
How are the methods named instead?
No idea
Hey I am getting the error:
java.lang.UnsupportedClassVersionError: net/fakkamc/Main has been compiled by a more recent version of the Java Runtime (class file version 63.0), this version of the Java Runtime only recognizes class file versions up to 61.0
However I am using JDK 17 to compile, anyone know how to solve that?
I am using maven
Looks like you're using Java 19 to compile
Also
?main
tyy
does someone know alot about how yml configs work
i have a question about what type i will get returned if its a parent of some variables
?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!
?
i asked the question, but if it wassnt that proper asked i hope its good now?
if i try getting a parent in yml what type will it return
player:
time:
join: 6:00pm
so imagine i have this if i ask for player.time what will it say?
thx!
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
?cc
Is there a way to disable my Plugin if something in the onEnable does not work?
I'm looking for an Bungee solution
isnt there a pluginmanager you can ask to disable the plugin?
💀
So you just disable the commands an forget about the rest ? as there is no disable function ?
You can handle internal not just enabling the features you have
so i'm trying to make a new ender dragon phase when it gets to half health it will get a lot harder and the dragon should be a lot faster. but i just can figure out the speed part so it flys faster. here is my current java class: " @EventHandler
public void onEnderDragonDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof EnderDragon) {
EnderDragon dragon = (EnderDragon) event.getEntity();
double health = dragon.getHealth();
double maxHealth = dragon.getMaxHealth();
// Check if the ender dragon is at or below half health
if (health / maxHealth <= 0.5) {
Bukkit.broadcastMessage(ChatColor.RED + "The dragon is now at half health - now its true power rises!");
// Set the ender dragon's custom name to "Fast Ender Dragon"
dragon.setCustomName("garry");
for (Player player : Bukkit.getOnlinePlayers()) {
Location location = player.getLocation();
player.playSound(location, Sound.ENTITY_ENDER_DRAGON_GROWL, 0.4f, 0.4f);
// Set the ender dragon's custom name to be visible
dragon.setCustomNameVisible(true);
// Set the ender dragon to be glowing
dragon.setGlowing(true);
}
}
}"
put your code in a code block
how?
three backticks (`) at start and end
bet
public void onEnderDragonDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof EnderDragon) {
EnderDragon dragon = (EnderDragon) event.getEntity();
double health = dragon.getHealth();
double maxHealth = dragon.getMaxHealth();
// Check if the ender dragon is at or below half health
if (health / maxHealth <= 0.5) {
Bukkit.broadcastMessage(ChatColor.RED + "The dragon is now at half health - now its true power rises!");
// Set the ender dragon's custom name to "Fast Ender Dragon"
dragon.setCustomName("garry");
for (Player player : Bukkit.getOnlinePlayers()) {
Location location = player.getLocation();
player.playSound(location, Sound.ENTITY_ENDER_DRAGON_GROWL, 0.4f, 0.4f);
// Set the ender dragon's custom name to be visible
dragon.setCustomNameVisible(true);
// Set the ender dragon to be glowing
dragon.setGlowing(true);
}
}
}```
Not sure you can change the speed of the ender dragon at all
breh
maybe try adding attribute
Try doing it with attributes how you usually do it.
i looked a bit in to velocity but im not sure if thats even a thing
It might not even use them though, the ender dragon is a bit iffy
try adding an attribute modifier for Attribute.GENERIC_MOVEMENT_SPEED
sure but im not really that good at coding spigot yet so ill just have to learn some stuff about attribute's
thanks a lot
ok
np
declaration: package: org.bukkit.entity, interface: Player
Click the link
Scroll down a bit
Use the javadocs guys
It does
Before, as you append comments to keys in SnakeYaml, which is what bukkit makes use of. So the configuration-section has to exist before you can append a comment to it. As soon as it exists, it shouldn't matter in which order you perform these two calls.
As in how much total exp they have?
?paste
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/HumanEntity.html#getExpToLevel() if you are smart enough you can do the maths yourself
declaration: package: org.bukkit.entity, interface: HumanEntity
how can i disable the alert [Server: Mostrando la particula minecraft:dust]
is the alert from the command /execute
minecraft:execute
I'll give you are tip: It's in server.properties
Server operator feedback or something like that
broadcast-console-to-ops=true?
most likely
But since it is very possible that these maths have an error, here is my approach @last temple :
float remaining = player.getExpToLevel();
float remainingProgress = 1F - player.getExp();
float fullLevel = remaining / remainingProgress;
float exp = fullLevel * player.getExp();
Hey, how can I make it so my custom enchant (Essence enhancer) which I use random.nextInt() to increase the range of random outcome on the breaking of sugar cane changes per level, bearing in mind I am wanting to have like level 500 maxed out
Oh man, it's funny how many people had to implement this exact calculation themselves just because the bukkit API lacks a way to get such basic information...
Is the only issue your random stuff or something else?
Discord using a different library for syntax highlighting now?
Probably
Yes, or they changed the color scheme
Weird. Definitely preferred the old one
Same
Like I just want the bounds to increase dependant on level but no idea how I can do this and alos then say level 500 is max (never worked with custom enchants before)
So do you want to have a gauss-like curve and shift it so it averages on higher values when you have a higher level?
Lemme open up inkscape real quick to sketch something
Too late, I don't care about upstream versions. I only care about version independence.
Yeah so the igher the level the more essence you have a chance of getting, the lower bounds staying the same and the uppder bound of random.nextInt() changing dependant
The port has to be known, as that's what the socket server listens on, and the IP is assigned by the operating system using either DHCP or static IP assignment, so the most easiest way would be to issue a GET request to a public (and reliable) what-is-my-ip API to resolve that. No idea if there are any easier solutions tbh, never needed that.
I have an issue with the website can i post it here?
Not exactly a development issue, I'd post it in general. But that's just my opinion.
int upperBound = (int) Math.round(random.nextGaussian() * level + 100);
int randomInt = lowerBound + random.nextInt(upperBound - lowerBound);
kk
Whats best way of setting levels? An enum or?
ThreadLocalRandom.current().nextInt(lower, level + lower)?
Using gaussian stuff would be a big ugly in that case
Wb setting levels
You wouldn't set 500 enum values manually, would ya?
Just do an Int or smth a short or whatever u want.
nah lol
I mean like I have the enchantment class, extending Enchantments with implemented methods. Never used it before so it obviously has its own level method so figuring out how to create a getter to it
I have never worked with custom enchantment plugins that do it the traditional way of extending enchantment, so I cannot tell
use 1.19 in plugin.yml and pom, and just check to make sure nothing you're using was deprecated in spigot's 1.20 release
well, rather, if something you are using was already deprecated make sure md didn't actually remove it
but that's very rare
Just use [1.19,1.20] (or somethin like that) in your pom
Although event constructors tend to get changed from time to time
does api-version take an array?
what field is that in the pom
i would seriously advise against depending on multiple versions at the same time if that's the implication here
Can't you use NBT?
meant something like that
I use https://github.com/Geolykt/EnchantmentsPlus/blob/4xx/src/main/java/de/geolykt/enchantments_plus/compatibility/enchantmentgetters/LeightweightPDCGetter.java#L166-L175 to store enchantment levels, but that is not how YOU should do it
I mean't for versions
maven-metadata.xml 🥳
You can - paper also uses snapshots
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/maven-metadata.xml is how it gets it for the curious
(I've spent too much time on my resolver)
spigot works pretty hard to maintain backwards compat. servers running 1.20 should have no issue running a plugin written for 1.19 so long as they're not doing something wack like touching something unsupported (cough cough) or were being naughty and using deprecated code instead of a documented alternative and that deprecated code was then actually dropped (haven't actually seen md do that)
The only thing that will break your neck is the new Material API
I really hope they will use two classes in the future
But from what I heard they will just overwrite the old Material enum
Soon ™️
It was announced with 1.18 (or 1.17?) I think
Future API
There are plans underway to change the way many enums in the API are handled so that custom content can be better supported. These changes are not expected to break most plugin jars (backwards compatibility will be provided), however they may unavoidably break plugin source code (though the Maven version will be bumped if this occurs). To reduce the risk of breakage, please consider avoiding the use of switch statements and EnumSet over enums which implement 'Keyed'.
1.18
That's some wizardry to me
regestries
🥺
This change has been coming for what ... 5 years now?
Yeah you're a wizard man, fair play
Yeah, pretty much
How long you been coding for @quiet ice ?
Seriously (i.e. like 30 hours a week)? 2 1/2 years now. But well I did code well before that, just very rarely
Don't worry, the code will still run, just not compile
HOWEVER
Unless you use eclipse
The eclipse compiler does not act differently to switch-on-enums when the enum is not an enum I believe
I just know Eclipse compiles stuff with errors sometimes.
If they use hacks similar to those that I use over on my galimulator modding toolchain, it would still compile AND run
That being said I can pretty much guarantee that they won't implement these hacks - they require advanced bytecode manip wizardy
Any good learning pages etc you can link me to imporve? I feel like i'm stagnating at the minute :/
I learnt so much so quickly now i'm just at a stuck position
Or well, with that I mean just doing a quick and dirty node.access &= ~Opcodes.ACC_ENUM; or somthin like that
It's enabled by default, but those are generated at compile time, not at runtime with already compiled code. e.g. if the compiler detects compile-time errors, it replaces the method stub
Actually it might not even be enabled by default anymore
Even if it is, you have to explicitly tell it to do it
I know some spigot people are dumb and do it a lot either way.
Atleast they did when i was active a few years ago
Thank god
Actually no, the hack is node.access |= Opcodes.ACC_ENUM
You can specify a different compiler with Maven (in fact, Bukkit uses the Eclipse compiler because it doesn't require a JDK), so I do wonder if it's possible to enable that functionality. You'd seriously have to know how to configure Maven to do it though lol
Adding ACC_ENUM means that the compiler thinks that the non-enum class is actually an enum and does allow stupid shit with that.
me trying to extend Enum 🥺
The most amount of backwards compat we'll be doing is re-adding the static methods that Enum provides. That's about it
That is possible if you remove ACC_ENUM from an enum, which was the hack I was thinking of in the first place
And non-static methods like ordinal() I believe also are being re-added. I can't recall
And hopefully .name() and so forth
Yes
you mean like flags on the bytecode?
Yeh
🫡
I.e. I have a custom version of fabric's accesswidener that allows me to do
# Enum Hacks
compileOnly denumerised class snoddasmannen/galimulator/EmpireSpecial
compileOnly denumerised class snoddasmannen/galimulator/FlagItem$BuiltinSymbols
extendable class snoddasmannen/galimulator/FlagItem$BuiltinSymbols
compileOnly denumerised class snoddasmannen/galimulator/MapMode$MapModes
extendable class snoddasmannen/galimulator/MapMode$MapModes
I'm trying to check if a player who is in ArrayList dies and if yes, run another code. I tried to do
if (arrayList.contains(player))
but that didn't work. Then I tried to do a loop for all players in the ArrayList and see if the player that died is there.
`for (int i = 0; i < arrayList.size(); i++) {
if (player == arrayList.get(i)) {
}
} `
also without success. Does anyone have any idea how else this could be done?
Compare playerUUIDs I guess
Are you sure that it is in that arraylist in the first place?
use a Set<UUID> instead ^
in Players case you can use instance comparision, except if they died
contains should to it.
Although, even if they died I do not know
Your issue lies elsewhere most like.
But yeah, contains should do it
only if they leave the server the object is invalidated iirc
Correct, but only if he does not hold a reference to it.
Eh, pretty dead to me then
is a weak hashset a thing?
wait the server uses a weak hashmap to ensure exactly that?
Kinda
ah its not in the java stdlib
If there is a map, you can use it as a set (for read ops it is just as easy as calling map#keySet())
And, one more thing, I am storing strings with player names.
💀
You can use Collections#newSetFromMap
keep in mind that if a player changes his name, that name wont longer match, use uuids are they will always be the same
Yeah, but this plugin is just for one use
AND be especially aware that you can no longer lookup the player name history
So what is done there cannot be undone
so that means youll make it dirty?
No, but i need just names and players more likely don't change their name during event
You can easily just keep a List of type Player and use contains, as Player is a "singleton" per login-session. You can even use == instead of equals, as it will - of course - have the same memory address.
Just make sure to use a weak referencing collection to not cause a memory leak after the player left. So many plugins make this mistake and are the reason that so many servers have to reboot daily.
Ok, and how can I store player to ArrayList using his name? Can I use Bukkit.getPlayer("name")?
How do I use NMS to change an entities AI?
Why do you want to store their name? What purpose does that serve, what problem do you solve by that?
I'd advise a collection like this:
Set<Player> deathWatched = Collections.newSetFromMap(new WeakHashMap<>());
Then use add and contains on it.
Well, I am using command /event add <nickname> and nickname is string, so I need to somehow get instance of player
Server#getPlayerExact(String) (can return null if no such player is online, also is case insensitive)
Sure thing, that's also a good solution, actually even better than the weak set.
i really didnt already say that 💀
Just depends on what you want to accomplish. But if you only use contains and do not want to iterate players, then you already have the player instance handle and thus can easily check contains with Player#getUniqueId. Otherwise, it would be stupid looking up the UUID in an iteration each time, for example, which is why a weak ref collection would be preferred there.
No need to feel shaded, we all appreciate you. :).
Not sure why it always has to be an overcomplicated topic. Using the Player instance? Hold a Player, make sure you clean up on leave. Not using the Player instance? Hold their UUID
welcome to #help-development
Why overcomplicated tho? I mean, sure thing, as I guess that the PlayerQuitEvent is guaranteed to be called on a socket connection close, removing from the collection at that point in time should be sufficient, but what's so wrong with using a weak reference to not have to think about this at all? It's kind of hard to argue about complexity or efficiency on that, it more likely is just a question of personal taste.
In all likelihood you're saving data on quit anyways
At least in any situation where I'm holding a Player, that's true
Likely, yes, but it seemed to me that they were only keeping this list to flag players who's deaths are watched and somehow processed. But then again, a UUID set would've been more than enough, that's what I should have advised them to use. Just that it's hard to decide on this if you don't know what operations will be performed on that collection and for what purpose.
In NMS if I wanted to create a custom entity that appears as an iron golem would I need my entity class to extend IronGolem or implement IronGolem??
Try both, your IDE will tell you.
Well it says "no interface expected. change to implement IronGolem?"
IronGolem is not the nms EntityIronGolem is it?
I have programmed a lobby plugin and a bansystem plugin and now I want to make these two plugins into one plugin. How does this work?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Why can't you tell me. I have described everything I want
I don't think what I'm using is NMS though I was told the best way for me to create my custom entity would be NMS as I need to basically change the AI of an Iron Golem to a wolfs AI but I have never done anything with NMS and can't find anything to help me learn or do anything with NMS
You basically combine the files between the two... then on top of that change class names so they match then you are done.
You have told me what you want, but not your code. One of the things we need to know is all your code so we can suggest the best way to merge it.
Why do you need my code to tell me how to combine two plugins?
Due to how coding works.
It's simple really
How did you manage to write two pretty demanding systems without knowing how to merge them? That's what I'd love to know, xDD.
probably crtl c, ctrl v
There are a few reasons why it would be helpful to see your code when trying to help you combine two plugins:
-
It allows us to understand how you have implemented the individual plugins and how they are interacting with the rest of your code.
-
It allows us to identify any potential conflicts or issues that may arise when attempting to combine the two plugins.
-
It allows us to provide more specific and accurate guidance on how to modify your code to successfully combine the two plugins.
Without access to your code, it is difficult for us to accurately assess the situation and provide meaningful assistance.
Could just ctrl c ctrl v them together, right?
Yeah and then ask us how to fix this syntax error.
What is difficult about a lobby system and a bansstem?
M8
does bungee even have banning, isnt that handled per server
Are you just that inept? Coding can be done differently in a million ways. We need to know it so we can fix it for you if you are not adept enough to do it yourself. As said in the message i just posted.
Bungee can have banning, but it's more of a plugin thing. Bungee could just deny proxy connection etc, if they are banned in their database.
ah yeah, makes sense
We are here to help, not steal your code.
If you can't merge your code, we probably don't want it either.
if the lobby plugin is proxy, and the ban system is spigot, you would need a check to tell where it is to enable/disable other code
I guess i'll just tell him some general steps
To combine two plugins into one, you will need to merge the code from both plugins into a single file or set of files. This will typically involve moving the code for one plugin into the same directory as the code for the other plugin, and then modifying the code to work together as a single plugin.
Here are the general steps you can follow to merge two plugins into one:
- Create a new directory for your merged plugin.
- Copy the code for both plugins into this directory.
- Modify the code to work together as a single plugin. This may involve modifying function names, class names, and variables to avoid conflicts.
- Test the merged plugin to ensure that it is functioning as expected.
- Package the merged plugin into the appropriate format for distribution.
Keep in mind that merging two plugins can be a complex process, and it may require some significant effort to get everything working correctly. If you are not comfortable with programming or if you are not familiar with the code for one or both of the plugins, you may want to seek help from a more experienced developer.
It was about bungee? Well, yes, putting a ban-system on bungee would be pretty smart, as you can intercept the player connection before they even reach a subserver. You got their UUID, so that's enough.
because its lobby i would guess thats bungee
Could be a plugin for the spigot lobby server.
ah true
I also want to combine two plugins of which I do not have the source code
you cant
Oh, now everything makes much more sense
the simple answer without source code just is impossible
How did Garkolym do it with Cashploit. Plus he has combined two plugin with ONE command
If you do not have the source code for the two plugins that you want to merge, it will not be possible to directly merge the code as I described in my previous response. Instead, you will need to find another way to combine the functionality of the two plugins.
One option could be to use the two plugins together in your server, and configure them to work together as needed. This may involve setting up communication between the two plugins using plugin channels, or using some other method of integration.
Another option could be to create a new plugin that relies on the two existing plugins to provide the desired functionality. For example, you could create a wrapper plugin that loads the two other plugins and then provides a new set of commands or features that are built on top of the functionality provided by the other two plugins.
Finally, if you are unable to find a way to use the two plugins together or to create a new plugin that relies on them, you may need to consider finding alternatives to one or both of the plugins that can provide the desired functionality.
well yeah, if its maven you might get lucky and they include pom but if its gradle you would have to guess the deps other than spigot-api. And then transfer all the decompiled code from those plugins
who and what
are you sure he didnt just get source code
How are you not asking Garkolym directly, if you know they have a solution? :)
^^
Some script kiddy which got pretty popular. xD.
This is why i still refer to spigot people as dumb.
Some sets can have.
HashSet can not, you are correct.
Yes
Yes? I'd say that the definition of a set is to only contain unique elements. The only way that would be possible is if the set cannot determine equality, based on some conditions I cannot think of right now.
What are yo ueven using used for
Ah, yeah that's correct my bad.
are you tired
xrandr --query
life of a linux user
also didnt you fix that
im not even getting a shell lmao
sleep
💀 lifes over
brain wil brain again
The weekly reinstall.
if i wanted i could use linux
lmao i reinstalled it like 5 times this week
and have 0 issues
youre using linux mint lmao
ill download vmware
dont care
im just here to boot debian and ratio you
ill do it later
im eating now
i got this far, then i rebuild smth and it breaks
Question. If I summon a custom entity that implements the IronGolem class(so that its a golem with custom AI). If I set it to be a village golem would it then attack a player if I set the player as its target?
why do you delete folders in ~
i love how most distros have protection for shit like rm -rf / these days
😢
removes the root lol
oh cool
atleast i know what -f does and experienced it :(
ill install another linux distro later just to run that
somehow i dont think rm rf / would work on wsl
we can just get alex to run it on his vps vms
Imagine being hacked through your local IP
i paid for the whole ram im gonna use the whole ram
What is wrong?
String msg = "test";
sender.sendMessage( new ComponentBuilder(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', msg)))
.create());
cat /dev/random
thats just random crap right?
new discord java format is soweird
yes
true
send them the TextComponent
man I used to have a full list of random fun commands
tf is this site
What would the best way to create an Iron Golem that would basically act like a wolf be?
chinese javadocs
packets i would guess
not NMS?
PACKETS?!
CommandSender.Spigot#sendMessage(BaseComponent[])
you might, no idea. Packets without protocol lib would require that anyway
The method create() is undefined for the type TextComponent Wiki.java /DarkSocials/src/me/Marek2810/DarkSocials line 18 Java Problem umm
Packets are NMS, just saying. You very likely need to do something along the lines of inheriting from a wolf and changing it's appearance, no idea how that's done tho as I've never done it.
Using packets could work, but is not a smart idea, as you'd have to simulate the whole AI yourself, which is a nightmare.
make an irongolem
remove its target and goal selectors
and then assign those of a wolf's to it instead
remove the create
I just checked the wiki.vg which is supposed to have all packet stuff and if I was to do it with packets it would literally require building the entire AI myself...
Which ya know
sender.sendMessage(TextComponent.fromLegacyText("my text"))
I don't feel like building an entire AI that already exists
You could intercept the entity creation packet and patch it to be a wolf, haha
thanks
Only that server-side hitboxes would be all messed up then.
no u dont
again
That sounds very good tho, I'd start looking into overriding goals.
Cause I want the entity to be an Iron golem but for it to do things like attack things that attack the assigned player and attack the things the player attacks
How would I override the target goals?
create an iron golem
get its nms object
clear its targetSelectors and goalSelectors
then look at the wolf nms class
and assign what they do in there for the iron golem
I tried to find something for NMS and this is what I made based off of that. Is this a correct NMS class for creation of a "custom" entity like this?
what class is getBlockInventory on
that would get the chest inventory probably
get inventory might get player
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Chest.html#getBlockInventory() looks like it
declaration: package: org.bukkit.block, interface: Chest
?conventions
looks like it shouldnt
only CraftChest#getInventory is implemented in that class
Dependices issuse [not sure if its]
it calls getBlockInv
it checks if the chest became a double chest if i seem to understand it
u dont have to create an nms version
unless ur trying to display it using a packet
so its not a server side entity
you can simply do
Not even then, let the bukkit API do the heavy lifting and just access it's handle.
How helpful indeed.
anyone have idea about this ?
#1061347663792054282
if they dont know the right naming conventions why are they doing nms
To solve a specific problem at hand, not to be a smartass about it.
the org.bukkit IronGolem golem = world.spawnEntity(...);
CraftIronGolem bukkitGolem = (CraftIronGolem) golem;
the nms IronGolem ironGolem = bukkitGolem.getHandle();
u could even skip that second line and go to
the nms IronGolem ironGolem = ((CraftIronGolem)golem).getHandle();
naming conventions dont have to be memorized
to use nms
naming conventions dont determine ur skill level to a point where ur not knowledgeable
???
anyone 😦 #1061347663792054282
I love how many people use the word idiot out in public against others, even they themselves are immensely ignorant towards the true art of engineering. Getting into programming has been made so awfully painful and unbearable by all the egomaniacs in this field.
the true art of engineering?
go take a look at C++ and youll see what happens when there are no naming conventions
I think I did something wrong but I don't know what. I created the ironGolem in the way you were saying(thank you btw) and then I tried to get the target and goal selector objects but it only shows what is in the picture.
need remapped or smth
not everyone is proficient in their language and not everyone knows naming conventions right away
i believe you have to use buildtools to get the remapped version of spigot
I tried to follow how to do that and it told me to run the build tools then just add a dependency with a classifer of remapped-mojang
i dont know the steps of getting a remapped spigot but i remember it was written on one of the forum threads
yeah
did u do so
I did so and it intelliJ threw an error that it couldn't find the dependency
did u reload maven
I believe so.
i just broke my ears with earbuds at 100%
Yes, in essence the art of problem solving. For you to know conventions and to make use of socially accepted patterns does not at all make you a better programmer. It's such a superficial rating which does not at all have anything to say about the approach itself.
You convention and pattern guys turned 90% of computing into a complicated clusterfuck of rube goldberg machines which look good on the outside but rot on the inside.
There are so many kind people which could bring useful ideas and approaches to the table and you just discourage them from playing in the world of logic by being a smartass and talking their approaches down.
Sorry for the rant, I'm not going to talk any more about this topic.
?switchmappings
thanks
Getting " Could not pass event BlockPistonExtendEvent" "Array index out of range: 0" if the piston extends anywhere. If the piston is besides the block from the list the event works without any problem.
e.getBlocks().get(i)
You assume that e.getBlocks() and testDataList are of same size, which is of course not (always) the case.
probably want a nested for loop
This is one of the most unpopular but good opinions I've read.
How would I go about doing that? I cleared the goals and then tried .addGoal but it asks for an int and I'm a bit confused.
So what could I change so the event works only on my list and not throwing that error
the int is the priority
look at the wolf class and just use the priorities and goals they use
and which selectors they use
just told you
also that isEmpty isnt needed
I could patch up the code for you, if you could provide a paste for it, so I don't have to manually type it out all over again.
Where do I find the wolf class?
in the same package as the nms irongolem
In essence you want to loop your list of TestData entries and compare each against the blocks of the event. If one matches, break the loop and cancel the event.
scroll up in the nms irongolem class and left ctrl + click on the package
thanks
Too complicated to understand through text explanation, I just started working in Java a few weeks ago. Here is the paste if you can patch it for me https://pastebin.com/LPTTQZU4
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
https://prnt.sc/Xk3ljAq0S3Sy - Errors
https://prnt.sc/1sjfl9oWd2aC - Server Console Errors
https://prnt.sc/ec2M4aLu3jzW - Library
Failing to use any dependency. (1.19.3)
wanting to use Fastboard
https://paste.md-5.net/ubivubolov.cs
Here you go! I understand what you mean, but this is not a Java problem, but rather generally applicative logic. You have two lists and want to check whether one list contains an element of the other list, based on a key (it's location), so you need two nested loops to check every element against every element.
maven install it
How to delete vehicle from existence ?```
public void onPlayerVehicleDestroy(VehicleDestroyEvent event){
if(event.getVehicle().getType() == EntityType.MINECART_HOPPER){
Delete destroyed vehicle
}
}
Tried: event.getVehicle().getLocation().setY(-20); and event.getVehicle().remove didn't work.
https://blog.jeff-media.com/manually-installing-jar-files-to-your-local-maven-repository/ use that to add fastboard to maven local
dont add jars to intellij, or use system scope
anyone know whats wrong with this SQL statement? I get an error when putting it through to a prepared statement
INSERT INTO test_collection (employee_id TEXT, name TEXT, age INTEGER) VALUES (?, ?, ?);
Caused by: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (near "TEXT": syntax error)
PreparedStatement statement = this.connection.prepareStatement(query)
this is the line of code displayed in the error so I know it has to be with my sql statement
TEXT isnt valid im guessing
Sorry if that question seems stupid, but is a destroyed vehicle not by definition destroyed and thus not within the world anymore?
entity#remove()
hmm? thats so weird its valid for my other project?
driver stuff maybe
I did downgrade the driver to be the same as spigots so maybe its that?
its probably that
How would I make it so that an iron golem is "tamable"(more that they spawn tamed) so that when setting their goals and targets to be the same as a tamed wolf they will still work.
Thanks, I will try the code rn. So a nested loop is a loop in a loop?
you put the wrong to main class in your plugin.yml
you would probaby need to listen to interact at entity or something like that even and changethe wolfs data
the class is correct.
The error seems to imply otherwise
I don't think it is
or is it due to 2x the same name
Exactly, nesting means putting one statement inside of another, where the for-loop is called a statement in programming terming.
I think you misunderstood. The iron golem is meant to act like a tamed wolf at all times(basically it spawns as an iron golem that will do the same things a tamed wolf does for the player). Its not meant to be tamed by someone its meant to always be tamed.
Don't think so, TEXT has been there for ages.
Ok, thanks for helping me 🙂
just use proper Format for your packages into your project
com.github.[yourname].[project-name] or me.[yourname].[project-name]
if you own a domain do
[your domain backwords].[yourname].[project-name]
for example mine is for my current project
sh.miles.megumi
sh.miles is my domain
megumi is the project name
why is the domain backwards
you dont need to specify the types when inserting, only the names of the fields
I never know how to set this up, what the logic for it is
I think you don't supply the column types in an INSERT statement, as the table definition is already known at that point. Have you tried without them?
the best way you can do is set group to me.yourname and artifiact as the project name
Alright.
no I haven't, odd that its just started acting up now though if thats the case 🤷🏽♂️ well might as well get rid of the types if you don't need them
how do I name this then
like: me.name.project
i also said that lol
me.attixcll.soilscoreboards
I think the SQL grammar doesn't allow you to do so, how did you ever get away with that?
this
no clue could've been an up to date version of the driver that just ignored it, and it doesn't ignore it on this older version
I don't think that any driver would accept malformed grammar. This is not a convenience, but actually breaking a very important rule. Are you sure that you successfully ran an insert statement with column types before? xD. But anyways, did it work after you removed those types?
yep, also haven't tried yet
wait no I was wrong I was looking at the wrong statement I c you now my SQL grammar was off and got tripped up by a copy paste from wrong spot lol
I somehow always fuck up the stupidest shit xD
uhh..??
Hey, anybody else getting the issue on 1.19.3 where if you try using the InventoryClickEvent event and then click on an empty slot it doesn't fire?
should I rename the SoilScoreboards to Main?
are you using paper
Well, do you have any other persisting problem now, after switching everything up a few times? Haha. If so, let me know, happy to help.
uhm yes
works now thank you
they probably cancel it
The path of main does not point at the correct fully qualified name of your main entry point (JavaPlugin). It needs to be me.atticsoil.soilcoreboards.SoilScoreboards. Btw, you're missing an s in soilcoreboards in your package.
I noticed
No idea why specifying the main path is still a requirement, it's so easy to find the only class extending from JavaPlugin. Oh well.
starting 1.18.2+ empty slots don't fire inventory click event any longer
afaik this is just a weird mojang decision
org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.atticsoil.soilscoreboards.SoilScoreboards'
Did you fix the spelling in your package
Yes
Image of the file tree please, haha
oh ok
tty
File tree of your IDE, the thing which shows packages and classes
did you repackage?
I rebuild the artifact
do mvn package and put the jar from /target in your server
uhhh?
press control twice then type mvn clean pacakge
Mind sharing your jar? Looks like you don't have much in there anyways, but it would help me to make sure you did everything correctly. Looks like a weird issue...
Attach it here
how do i serialize itemstack into a yml
Do you guys just assume that this is a maven project? xD
Anyone willing to help me with creating an iron golem that would basically act like a tamed wolf without needing to change the iron golem class to be a tamable animal?
its serializable so you can just use set(path, item)
theres also a getItemStack
wont it error i tried it with a normal class and it tripped after reloading
wdym
Seems like your build process is completely messed up. How do you build your jar?
if that class doesnt implement configurationserializable then the config will not know how to save or load it yes
A normal class !== a serializable.
^^
soilScoreboard
I'm trying to setup an iron golem that will act like a tamed wolf. I got the NMS object cleared the golems goals and then tried to set the goals to be the tamed wolves goals but it doesn't work because iron golems are not tamable and so not all the goals can be set on the golem preventing it from working
You can write your own goals
Tried like this didn't work or i'm doing it the wrong way ? ```
Entity minecarthopper = event.getVehicle();
minecarthopper.remove();
Hello, anyone have an idea of a solution? https://www.spigotmc.org/threads/1-19-chatevent-setmessage-does-not-work.583967/
Is their any premade config updated libs?
For updating a config
one of alex's plugins has one
What errors are you facing? Compiletime or runtime? Any messages/stacktraces?
The issue is that IronGolem isn't a tamable entity
What are you trying to remove? The destroyed vehicle? How's that still there after being destroyed?
and several of the wolf goals require a tamable entity
I think i found alex's plugin. ty
Yeah, still, can you be a bit more concrete? Like, show me an error message so I can see the tokens (class, field, etc names) used to navigate around in the codebase myself for a moment? I've never done this either.
ironGolem.targetSelector.removeAllGoals();
ironGolem.goalSelector.removeAllGoals();
ironGolem.goalSelector.addGoal(5, new MeleeAttackGoal(ironGolem, 1.0, true));
ironGolem.goalSelector.addGoal(6, new FollowOwnerGoal(ironGolem, 1.0, 10.0F, 2.0F, false));
ironGolem.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(ironGolem));
ironGolem.targetSelector.addGoal(2, new OwnerHurtTargetGoal(ironGolem));
ironGolem.targetSelector.addGoal(3, (new HurtByTargetGoal(ironGolem, new Class[0])).setAlertOthers(new Class[0]));
ironGolem.targetSelector.addGoal(4, new NearestAttackableTargetGoal(ironGolem, net.minecraft.world.entity.player.Player.class, 10, true, false, ironGolem::isAngryAt));```
Thats everything for the golem
I pulled the goals from the wolf class file
I don't think I'm legally allowed to just directly show you that
You're going to need to write your own goals or make your IronGolem tameable
How do i make it tamable
How would I learn how to do that?
Which one
You take a look at the existing ones
i mean minecart with hopper is destroyed and it drops as item so i guess i need to delete that item or something
Yes, you cannot just call remove on that destroyed vehicle entity, but have to call it on the dropped item itself. There's no connection between them.
when working with SQL is it okay to update tables like this? In this scenario I'm only technically changing the age, on the implementation, but in the back end I don't know whether name has also changed. In my scenario its not. Would it be better to just update a value even though it hasn't changed or store some copy of the data to check against what I need updated specifically
UPDATE test_collection SET name = ?, age = ? WHERE employee_id = ?;
damn thats a lot nicer thanks, but questions remains whether its okay to just overwrite values even though they are the same or whether its better to do some weird check for it
You can do whatever you want
Where do you call this statement? When updating what exactly?
e.g. I have a data object in this example its just called DataHolder
final DataHolder exampleData = new DataHolder(UUID.randomUUID(), "John", 20);
// insert data
collection.insert(exampleData);
// update
exampleData.setAge(21);
collection.update(exampleData);
its being inserted
than updating just the age, but then when I run the update query I update every value in the column, but the primary key even though they may not have been a change
UPDATE test_collection SET name = ?, age = ? WHERE employee_id = ?;
Oh, right. Well, whether that's okay depends on whether you're the only person operating on this dataset. If you are, that's fine. If other processes can also manipulate it, you could loose the name they updated, for example, as you just override it without even checking for differences.
alright thank you
But I don't think that you're actually doing the multi-access stuff, as that requires a whole other level of things to think about.
keep a boolean in your object whether its updated
thats super crazy you'd need a boolean field corresponding to each field in the class
just one field
I mean I could write byte code to do that , but I rather not
No, you should just track whether any field has been updated. Like, keep a boolean called modified, and set it to true in each setter, than set it to false in update. And in update, early-return if modified is false.
With this little addition you can avoid having useless updates which don't actually update anything but tax the system
oh before I just did an exists query
but that also works i suppose
It's not about exists, it's about not issuing an update with the exact values already in the DB
you still have to do some insert or update check (upsert, as it's often called).
is there a good way to calculate how much time the breaking of a certain block with certain tool would take ?
don't think the api has a method to do this as far as i know
if those updates are done async and youre not waiting for them to return it doesnt matter
unless youre trying to limit the amount of queries
so what I'd do something like this
void setName(String name){
this.name = name;
this.modified = !this.name.equals(name);
}
I always run my DB stuff async unless its on startup or shutdown
I'd actually compare before updating the local field. Also, the boolean update has to work like a latch, only setting it to true but never to false. Only clear the flag when issuing an update statement
But again, you can scrap that, it's nitpicky performance stuff which keeps you from solving the problem at hand.
dafuq is |=
Oring and assignment in one
Bitwise or to be exact
It accomplishes the latch-like behavior I talked about earlier.
isDirty = isDirty | oldValue != newValue
i believe | works the same as || for booleans
but ||= isnt a thing
uhh
It is same as "logical or" aside from | actually execute both sides if first is true
yeah
| is bitwise OR
it works for booleans as the logic just works like bytes internally
both sides execute regardless if the first one returns true or not
I'd honestly just do a markDirty method, as is usual practice
Because they are represented as integers internally, to be exact.
A method for wrapping a single or instruction? Seriously?
anything that's a short or byte is just represented by an int in the typical jvm
Yes
There's no guarantee that method will be an OR instruction forever
you can for example, have a logging system
for a replay system of some kinds in the future
Ah yes, there we are again. Overcomplication because "you could have x some day, be prepared!"
Yep yep, behave as socially accepted, just don't be different because it makes more sense in the current situation.
I couldn't care less
This is not about me, but about the person who actually persists models in a database and asked that question. But I get the idea, thanks.
I've just learned through years of experience, that preparing for a likely future is a nice strategy
I've rewritten my code lots of times
Over some very stupid changes
So I'd rather just write something future-ready even if it comes at an additional overhead
encapsulation and all
java will probably optimize that out anyways
That's where sophisticated refactoring comes into play rather than being overly prepared for every little if and when. But hey, to each their own, just didn't want to let that statement be the only one regarding that topic.
most likely at runtime
yeah, compiler optimization isn't something that apparent
i mean the compiler cant just inline a piece of code because it might be overridden or something
It's not about the subroutine jump, it's about it being an unnecessary jump for the brain of the reader.
So, what is cleaner
It can, as all paths are clear at the time of compilation. That's besides the point tho.
a = b;
markDirty();
save();
or
a = b;
dirty = (dirty | oldResult != newResult);
save();
I don't see the point but then again, we always seem to argue over code style
Because we both have different approaches
nah what if some external piece of code overrides the method or some shit
and I won't really go on about this as neither of us will change
its risky to optimize that out
Unanswerable in an objective manner. It's a personal thing, called taste, and depends on whether you're an actual engineer who's not afraid of bitwise logic, or whether you need to sugar-coat everything to make it understandable for everybody.
unless its marked final ofc
Your code will eventually get read by people who are not you
Don't take it seriously, :D. I appreciate the fact that you share your experience, that's needed in a healthy community. I just love to argue. There is definitely no wrong and right in this argument.
there's a chance they might be idiots
that chance is higher than the chance that it will be read by an actual bit magician
Okay, point taken.
seeing a "markDirty" and not understanding the internal logic
is still more helpful
than just seeing the internal logic
You also only have a single code block to change, in the event you actually want to change the implementation
or some idiot like me can make a class that extends it and overrides that method
for some patchy under-budget commission ;)
Is there a way to replace the prefix of the logging format for my plugin?
I wanted to have my plugin log with the prefix AdvancedEngines> but when I set the prefix option in my plugin.yml to prefix: "AdvancedEngines> ", the logs output [AdvancedEngines> ] <log message here> which isnt quite what I had in mind lol
(Ideally I would like to not use just System.out.println)
That should work. try to check if the code reaches the removal line
OOP at it's finest! :)
I've done that with bukkit's plugin manager once
and used unsafe to inject it into the server
choco wasn't happy
you could make a custom logger using Bukkit#getConsoleSender()
No, that cannot work, as a destroyed entity is being removed by definition. They're trying to kill the dropped item, which is a whole different problem.
A dropped item is an entity. why can't you do entity.remove()?
Isn't the main idea of this logger facade that's used there to avoid implementing your own logger? But to be honest, I also always do that, cause I never researched how.
You can, but the entity of that event is the vehicle, not the item. Wrong reference.
Fixed with this code```
Vehicle minecarthopper = event.getVehicle();
event.setCancelled(true);
minecarthopper.remove();
a minecraft and an item are both entities
i dont know but i also dont give a fuck, i did it because the logger didnt support chat colors
and it worked and looked nice
so yeah
imagine using a logger lmao
You don't get my point.
ssytem.uot.pirntln
you do that async rigth
The reason why that works is because cancelling the event cancels the natural death procedure of the vehicle and then removes it without dropping anything. This does NOT remove the item.
of course
How can I make it so that you can't put items in the gui?
its just a webhook n all
listen for someone moving an item, if the gui they're in is a custom one, cancel the event?
cancel InventoryClickEvent if a specific condition is met
like slot is not the input slot, then cancel
I did so, but despite this, if I try, I can shove an item in there
Software in 2023 in a nutshell, haha

And these items can simply be put in, but cannot be taken away.
Are you talking about shifting in? Because the click event is not the ultimate event, it doesn't cover all actions, IIRC.
Yes, pressing RMB with an item changes the item
how do i know detect if its the crafted item? (for instance im trying to create an iron sword that can be renamed to anything and has no lore (so there is no way to detect from the name or the lore that its that item) but when used, it damages the player instead of the entity u hit, which a regular iron sword cant do)
when i tested my gui manager on paper clickevent covered shifting as well i think
I might remember that wrongly, nevermind
So what should I do?)
Post the whole event as you seem to be missing certain cases.
okey, wait
is there a way to disable a recipe from a server without completely removing it
because my plugin needs to disable certain recipes but if you remove the plugin afterwards those recipes will still be gone
i just need some recipes disabled, so make them uncraftable and not have them show up in the recipe book, without completely removing them
or do i just deal with removing them and tell the users to return those recipes themselves
(cancelling the crafting event alone is not enough because they'll still appear in the book)
You add to the documentation that they need to run a command before removing your plugin.
is there a way to retrieve what the vanilla recipe used to be? because this disabled recipes list can be configured
or do i have to code in all the recipes just in case a player removes them lol
or using a workaround like persisting all the details of the recipes that are disabled
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
(Sorry for the messy code)
?arrowcode
any 1?
add some identifying tag to the crafted item and then when someone uses it detect if that tag is there, then do what you wanna do
i recommend PersistentDataContainer to add such a tag to the sword
^
it's invisible aside from the extra NBT tag in the f3+h view
which you cant really avoid
i tried this and then in an event detect if the item the player is holding has that data, but its null
what is null
naming conventions out the window
huh?
?conventions
the method should be createSussySword
also you can put the namespacedkey part outside of this method since you reuse the same key always anyway
but what is null
alr...... ignore the names plz, i tried to make this in a rush
this
@EventHandler
public void hit(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player player) {
if (player.getInventory().getItemInMainHand().getType() == Material.IRON_SWORD) {
if (player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().get(new NamespacedKey(Main.getInstance(), "suicideSword"), PersistentDataType.INTEGER)==1) {
player.damage(event.getDamage());
event.setCancelled(true);
}
}
}
}```
well the namespacedkey in your created sword is sussySword
and here you're looking at suicideSword
before you try to look at the value a PersistentDataContainer has you should also check for getPersistentDataContainer().has(...)
wont get() throw when its not present and you try to unbox
^
use getOrDefault
yeah get will throw that NPE
oh alr
thats why she should be using has() first
otherwise when you use literally any other iron sword it'll throw that error
is there i forgor
there is
anyone used yaml anchors before and know if theres something wrong with my format?
items:
ELYTRA: &ElytraItem
#Make them match the stuff on https://hub.spigotmc.org/javadocs/spigot/org/bukkit/enchantments/Enchantment.html or no enchant
Enchants:
MENDING: 1
DURABILITY: 3
Lore:
- "Lore Line 1"
- "Lore Line 2"
Name: "Epic Elytra name"
vote-gui:
1: *ElytraItem
just use a yaml validator online
i did now, but it still doesnt work
i dont get the exeption now tho
ah there was something wrong with my anchor/alias format
show code
?paste
what are yml anchores?
Anchors? Are you talking about references to other keys?
are you using the proper sword? if not just check which if condition fails
ye im using the sword i crafted
are you sure you didnt get any startup errors because i know minecraft likes to complain when you register recipes under keys that already exist
Where did you learn about that? Is it a standard YAML feature? If so, the question is whether bukkit's yaml wrapper supports it.
@tender shard showed me it a few days ago
idk i just did /reload confirm
he uses it in one of his plugins
it doesnt use any other yaml stuff it looked like
after re-formatting in yamlint
i have yaml of https://paste.md-5.net/axugovupav.makefile
but i get an error of https://paste.md-5.net/kijuvubobi.sql
just check the if conditions in that case, output a message in else statements. but first just make your namespacedkey private static, you dont have to keep remaking the same namespacedkey
and that way you also know for sure you're using the same one always
ok
I'm confused. I am trying to make an iron golem that basically acts like a tamed wolf(protecting the player and attacking what the player attacks). I have been trying to use NMS but I basically have to take all of the wolf goals and targets and rewrite them so that they actually work for Iron Golems. Anyone have any other ideas?
it was yesterday
hm or maybe wednesday
one sec ill go check
what you sent is valid yaml
in 3 hours it will havebeen 2 days ago
yeah thats the weird part
wait ugh
line 3
you say "&elytraitem
what is that supposed to do
it should be like this:
connect to the *elytraitem below, yamlint made me do it that way
same error
hm lemme check the error msg
interesting... it prints out "2" whenever i hit something...
@EventHandler
public void hit(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player player) {
if (player.getInventory().getItemInMainHand().getType() == Material.IRON_SWORD) {
if (player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(suicideSword, PersistentDataType.INTEGER)) {
Bukkit.broadcastMessage("1");
player.damage(event.getDamage());
event.setCancelled(true);
} else {
Bukkit.broadcastMessage("2");
}
}
}
}```
send your full config
one sec ill remove the db stuff
the config you sent doesnt match the error you got
do not remove it completely
just "censor" it
I need to know the line numbers
i mean then it doesnt match, which means the keys probably dont match
try restarting your server
that should work fine. are you sure that this is exactly the config your plugin uses? maybe check the plugin data folder, whether there's still an old config in that folder