#help-development
1 messages ยท Page 157 of 1
imlukas be careful you can get banned for reaction spam
Sadge
this is why I go to the gym, so I can break your kneecap breaking apparatus instead
and then make lines of code that are 100x longer
thanks I'll remember me too
Bruh
I really need to make this more resilient, I have the weirdest silent issues
I wonder why
code gremlins and people cursing my code under their breath
I just need to make sure I re-salt all the doorways and windows so the bad vibes can't get in
I don't know what you're talking about
they hate us cuz they anus
i prefer meth
I'm trying to learn Generics in java. Here's an example of something I am working with:
Line 11 doesn't work because the java 1 public class GenericClass<T>{ 2 private final ArrayList<T> list = new ArrayList<>(); 3 public GenericClass() { 4 } 5 public void addObject(T object) { 6 this.list.add(object); 7 } 8 public int getResult() { 9 int result = 0; 10 for (T index : this.list) { 11 result += index.getValue(); 12 } 13 return result; 14 } 15 16 }.getValue() method is found in the Class I intend to pass in through the diamond brackets <>. How can I call that method in a situation like this?
Nevermind, I realized that I should simply cast index as the type I'm passing in
I tried setting an entity's velocity to Vector(0, 0, 0) when I pull it with a fishing rod, but it does not stop the entity from getting pulled towards me. What should I do to stop the entity from moving to me?
yea how the heck did u get the numbers before the lines
did you aadd those manually?
~~```java
1
2 test
3
ah yes
@quaint mantle
uhhh
the second ~~ are wrong
This is purely an example I'm using to learn, I have no application intentions with this other than learning.
That's very cool
getResult is just an example of a method being run by a certain type
not found in the generic class
flatMap
Restrict the type parameter maybe
<T extends I>
then the type can at worst be erased to I
Well assuming I::getIndex exists
I ended up doing that, it solved the issue. Instead of casting to the type, I extended the type. Thanks
Another way is ofc to have something like getResult(ToIntFunction<T>)
(Without restricting T)
however the operand function does the mapping
How can I stop entities from being pulled with a fishing rod? I already listen to when the entity is being pulled, but I just can't manage to stop the entity from moving towards me
nvm
I can cancel the event and it won't do it
Actually no, that also prevents the rod from being pulled back
Is there a way to manually retract the rod for a player?
setHookedEntity(null)
set to null, the breakfast of champions
hi all, I'm trying to use a scheduled task but I can't seem to access variables declared in the class that the task is in in the runnable?
here is my task:
Bukkit.getScheduler().runTaskLater(Main.getPlugin(Main.class) ,
new Runnable() {
@Override
public void run(){
player.setLevel(((vel_x + vel_y) / 2) * 999);
player.sendMessage("Player speed: " + ((vel_x + vel_y) / 2) * 999);
}}, 20);
};
and intellij linter:
Correct, they have to be effectively final or Atomic
but i want to change them in the task, i cant have them as constants
looks to me like you only want to calculate not reassign
You can use a singleton array
doesnt final make the variables not able to change?
int[1]
Yes but effectively final is not the same as final
Effectively final usually means that the explicit variable used is non reassignable, but the content of the data the variable points towards is mutable
i think i get you, ill play around for a bit and see if i get it to work
Myeah
This method doesn't exist in 1.8 sadly. I tried removing the fishhook entity. This worked, but afterwards I couldn't cast my rod anymore. Do you have another solution?
is vel_x the x velocity of your player?
yes
ooooh of course
Is there a reason you only use x and y of the velocity? Seems an odd choice
its going to be wildly inaccurate as it ignores z
because the player is in a boat, I want to get the speed of the boat which wont be changing on the y axis
ok i'll look into it
Bro missed xyz day
oh that must be a mistake lol
im used to 3D printers where z is up
Why is a "a" being added to the start of the name?
String input = event.getCurrentItem().getItemMeta().getDisplayName();
int i = input.indexOf(' ');
String name = input.substring(1, i);
try {
event.getWhoClicked().sendMessage(ChatColor.GREEN + "Teleported you to " + name);
event.getWhoClicked().teleport(Bukkit.getPlayerExact(name).getLocation());
} catch (Exception e) {
((Player) event.getWhoClicked()).sendMessage(ChatColor.RED + "Could not find a player with the name " + name);
e.printStackTrace();
}
yep i now know why my numbers came out borked lol
also boats can move up and down so best to not ignore Y
where?
mf sent a screenshot that didn't have anything to do with chat
i can count a total of 4 "a"s in that screenshot and none are at the start of anything
A
that starts with an A can confirm
A
how to immue player knockback?
help
When it prints the can not teleport error message is say "aZoiBox" or "a8" or whatever
it adds an a
You should just use ChatColor.stripColor
I'll see, if this just works then it shouldn't be a problem
Hey, can someone give me an example of a string you'd put in Material#createBlockData?
I want to set a block's data from a dictionary, like for example "half=top" and so on
Any suggestion for good inventorylib
I Personally use inventoryGUI by phoenix616
what version does supports?
looking it, it should work on most
Hi im on programming classes bored
Could someone recommend a good for loader for java 1.8
Why is my dummy taking dmg when I hit it?
@EventHandler
public void onPvP(EntityDamageByEntityEvent event) {
event.setCancelled(true);
I will use it to load a remote controller done on Java on the computer. Because they permissions are okay. But java has root permissions
๐คก
Maybe another plugin interfering?
Idk how that'd happen, its registered
Time to Play mindustry
I mean could be another plugin overriding the event
Yeah I want to give a try to my school security
๐ช
It's my test server + I later in the method I cancel dmg in a cuboid and that works
OpenTTD and mindustry are the only two Games I Play at school
They are really clown because how the fuck they will give all privileges for java when you know that from java you can do dirty things too
I want to say however: If you indend to do anything harmful - DO NOT DO IT
You would regret it. Circumventing Security at Schools are No laughing matter
I mean I just will give a try of what I can do I wont leak data
Just talk with the director and told that they have security problems
I would do it as one of those ethical hackers
๐ ๐
playin mindustry too ๐ค
a what?
.
I like https://github.com/SamJakob/SpiGUI this api. Its easy to use and has alot of cool features. One problem is that it has an item hardcoded which I cannot remove. I've tried to set the slot to air, or another item but wont work. Anyone who knows how to remove it or maybe has a better API? Let me know
My school pcs are in land red but they are protected for executing programs. But what about java its has root privileges!!
didnt understand half of that sentence but anyways what youre studying?
So im looking for a java loader to inject a native jar which do what ever I need
no idea wth a java loader is
Im basically trying to test my school security
ah yes
Java loader is a java program that load and execute a jar in the JVM
if it doesnt have a jvm already installed and you dont have admin perms, i doubt you can inject something into a jar file to run jar files
Epic
Im doing that
The JVM has root privileges
I mean the computer itself is well protected but not as 100%
does the computer have java/jvm installed
So that why im looking for a java loader
Yes it has
Im planning to make a java code which load a custom jar hided and then execute native methods from a DLL
๐ค
I had to sign a paper that said I wouldn't try to hack things when I joined my school
Can someone pwease help me 
PATIENT
You are not playing anyone

If you need support wait patientlly and if you dont want to your message get lost open a Thread
HELP ME
I dont know why its so diff to do that
new Thread(this::askHelp)
Inventory API GUI APi
ok
how do i do a String <-> integer map (both directions) ?
Do you mean Integer (or char) array instead of integer map ?
Or what is your data structure ?
im asking generally how to make a map that links the objects on both sides to each other
Guava has a bimap
Because the map is not made to have unique values
collection then
thatd do it thanks
how do I check if a player has a potion effect
like has any potion effect, because hasPotionEffect() requires a potioneffecttype
dont I need to check if a player has a potion effect?
ยฏ_(ใ)_/ยฏ
can i use the return value of this and assume pos hasnt incremented?
looks like pos is incremented after value has been returned
i was thinking how jvm would be able to do stuff in that method if control was already given to another method
anyways
NoClassDefFoundError: net/minecraft/network/protocol/game/PacketPlayInUseEntity
people getting kicked with this error?
When they join they get kicked
Looks like it can't find that packet
could be a via version thing
Or their plugin
hi
?dontsayhello
What do you need
check the thread
?nohello
do you see it?
new Object();?

Object myEmptyObject = SomeClassForThat.createEmpty(MyCoolObject.class);
Class<?> clazz = myEmptyObject.getClass();
Field field = clazz.getDeclaredField("test");
field.setAccessible(true);
field.set(myEmptyObject, "value");```
Or do you mean sun.misc.Unsafe#allocateInstance?
I mean usually you want to get a specific constructor
Oh you probably mean allocateInstance then
You can call the constructor later on anyways
but can I assign the variables manually?
Yeah, it's a feature-complete object
You won't run any constructors though
So all fields are guaranteed to be either null, 0 or false
dust options are proof that god is dead and java killed him
How so 
the constructor is a nightmare and I never remember how to do it
there's more than just redstone that can be colorable right?
fireworks and music notes should work as well?
i miss the c++ style of defaults params :(
I miss sleeping
if (particle.equals(Particle.REDSTONE) || particle.equals(Particle.FIREWORKS_SPARK) || particle.equals(Particle.NOTE))
location.getWorld().spawnParticle(particle, location, amount, x, y, z, speed,
new Particle.DustOptions(Color.fromRGB(red, green, blue), 1));
data should be class java.lang.Void got class org.bukkit.Particle$DustOptions
was this not the constructor?
Nope, only Redstone uses DustOptions
FireworkMeta
Yeah I think fireworks spark is just the white trail it leaves behind
Which doesn't have a color
firework meta?
FireworkMeta is for making actual fireworks
sets the color and stuff
and notes?
what notes
ah
Uhh, maybe this would help? https://www.reddit.com/r/MinecraftCommands/comments/bnatf4/how_to_colorize_note_particles/
Looks like it's based on a 0 count with speed for some reason?
is it still illegal to murder people?
I believe so yes
ah
You could probably punch your monitor though that'd be fine
why would I punch the monitor, it knows how to do rgb without summoning Cthulhu
ah except you need to add colors not as rgb but individual elements
for the fireworks
meh
wait actually not this won't work
I am spawning the particle not the firework, is it not possible to do this via the api then?
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.block.CraftCreatureSpawner.setMinSpawnDelay(CraftCreatureSpawner.java:65) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3498-Spigot-b081915-10ba1be]
at me.waterbroodje.customspawnerplugin.listeners.BlockSpawnListener.onBlockSpawn(BlockSpawnListener.java:24) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 23 more```
```java
@EventHandler
public void onBlockSpawn(BlockPlaceEvent e) {
NamespacedKey key = new NamespacedKey(CustomSpawnerPlugin.getInstance(), "spawner");
PersistentDataContainer data = e.getItemInHand().getItemMeta(). getPersistentDataContainer();
//.get(key, PersistentDataType.STRING);
if (data.has(key, PersistentDataType.STRING)) {
CreatureSpawner spawner = (CreatureSpawner) e.getBlockPlaced().getState();
spawner.getPersistentDataContainer().set(key, PersistentDataType.STRING, data.get(key, PersistentDataType.STRING));
spawner.setSpawnedType(EntityType.COW);
spawner.setMinSpawnDelay(2000);
spawner.setMaxSpawnDelay(8000);
spawner.update();
}
}``` What did I do wrong lol
cache key and use pdc::getOrDefault
It was working before
But I was trying to change the spawn delay and then this happend
that error message doesnt make much sense
Why are you reinventing weed when it already exists! Just use it
Hello, is there an easy way to get the drops of an entity? For example EntityType.ZOMBIE drops rotten flesh, is there a method that tells me that?
LMAO
Maybe listen to drop event and the cause
stop reinventing weed pls
It's because I want to do something else with the items, it's going to be some sort of fuel for the mob spawner, and I need to validate the item when someone clicks on a spawner
I guess I'm going to have to store all drop items on a map with the entity types
the hell is a dust_transition
?jd-s
That is your best friend
You're setting min first
Set the maximum first
which would be helpful if that wasn't the way I found out about it in the first place
Thank you
why isn't the block setting to bedrock?
if (mineMaterials.contains(mat)) {
var random = new Random();
var amount = random.nextDouble(getAmount(mat));
e.getBlock().setType(Material.BEDROCK);
new BukkitRunnable() {
@Override
public void run() {
e.getBlock().setType(mat);
}
}.runTaskLater(CharmGenz.plugin, 50L);
return;
}```
it does get set back to the material
but doesn't get set to bedrock
what in-game feature has transitioning particle colors?
maybe there's a NMS method for getting the drops
heeheehaw
How do you know it gets set back to the original material if it's not changing to bedrock
because whenever i break it its just air ofc
and gets set back to the original material type
but doesn't set to bedrock
for some unknown reason
my god you need 40/20 vision to spot the particles on this one
What if you delay setting it to bedrock by 1 tick?
finally they'll be able to get into the japanese market
also
is there a better way of doing this
since im using 2 bukkit runnables
if (mineMaterials.contains(mat)) {
var random = new Random();
var amount = random.nextDouble(getAmount(mat));
new BukkitRunnable() {
@Override
public void run() {
e.getBlock().setType(Material.BEDROCK);
}
}.runTaskLater(CharmGenz.plugin, 1L);
Bukkit.broadcastMessage(String.valueOf(amount));
new BukkitRunnable() {
@Override
public void run() {
e.getBlock().setType(mat);
}
}.runTaskLater(CharmGenz.plugin, 50L);
return;
}```
i mean, i could use 1
and just set a var every tick
suggestions, thoughts?
how to give items a colorful lore?
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(<what comes here to make it colorful?>);
Write some text with the color codes ig?
You can probably cancel the event and then set the type, that would remove the requirement of the first one.
Because since you weren't canceling, you're setting the type and then the block is being broken anyways, which is why it wasn't setting.
okay, let me try
Use ChatColor or ChatColor#translateAlternateColorCodes
like this?
speaking of colors, I think this page is just massively outdated https://www.spigotmc.org/wiki/colored-particles/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
pft, thats it?
e.setCancelled(true);
e.getBlock().setType(Material.BEDROCK);
e.setCancelled(false);```
No you have to keep it cancelled
do yall think that a server looping thru main hands of 30-40 players would cause lag?
Nope
every tick
Yeah, should be fine
The server is calculating AI for every entity every tick, so doing something like that is negligible in comparison
ic
yo but if a player is seen with an exploitable item (chests with nbt lmao) should i clear all inventory or the hand item?
How is the player going to get a chest like that?
i think (im on mac rn) it was ctrl + middle click
Thats creative mode
You have near zero control over creative
yes but players can "ban" others by giving the item
Don;t allow players to have creative
you are entering into a whole world of hurt for yourself
I highly doubt that
Time to use Protocollib to remove all NBT from items
they don;t need creative to build, you just have to be good at coding to simulate it
you asking me to make a "creative" menu on survival?
yes
hah, try to explain it to people who play mc for first time
Then limit all yoru creative to a single world
wipe inventories when they join/leave the world
yes
me watching rust documentation to write java hmmyes
will this also cancel observers??
Not sure why as it should just work to whatevers set in the config?...
Help plzz, you need to make sure that another block appears in the place of the previous block, I tried it as it is on the screen, it doesn't work, but there is a message, what should I do?
Sorry for broke english)

how would i call a class that holds a char array to iterate over and a current position and is able to build numbers from those chars?
called it a StringReader first but might do CharBuf or smth
cancel event
world might be null too
why? I need it to run in event
youre changing the material
Well, yes
if it wasnt obsidian before you wont notice it being changed
How else can it be done then?
smh
change the material and cancel the event so your changes wont be overridden
ahhh, got it, thanks
hi bae'
What the fuck
๐ญ
wtf
its wasting chars lol
oh
uwu
also unoptimized asf
When I keep mouse on bukkit event it says javadoc could not be found. How can I add spigotmc javadocs in eclipse?
OWHH now i figured out why copilot was doing pos--
it was trying to debloat my code smh
???
just use ij lol
i have 4 gigs of ram. its not enough + 32 bit
MEHH
how can i check if entity is dropped item?
no
yes
What am I doing wrong rn?
is there an entity type?
kinda made it work
I've always found Eclipse's artifact Javadoc tool to be inadequate. I could never get it to work, personally
Using Maven resolves the issue just fine because Javadocs are auto downloaded as artifacts, but I could never do it via the classpath
I don't think Bukkit's Javadocs generate a package-list file so I believe that's why it's failing
so...
how can i fix that?
just use notepad
i have lot of projects on eclpse
Does notepad have javadocs? lol
lemme guess.. no?
how can i fix that on ECLIPSE?
idk
that seems kinda slow tho
never look at how Math.pow is implemented lmao
i thought it was 400 lines
ah 250
:/
close mc lmfao
and test plugins in air
is server running on ya pc too?
no
good
where are the javadocs in this jar?
i believe they arent included
;/
i fixed it with replacing https with http but still its not working
Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc.
aaaaaaaa
i get it
maybe this url gives me other minecraft version's javadocs right?
how can i check if entity is dropped item?
literally what you just wrote
thats the solution
isnt that Item class?
entity instanceof Item or whatever
^^
yes i dont know the class name
eh javadocs
๐
theyre useful when you can read
which means most of the time I ignore them
sometimes not Note: An exception occurred while getting the Javadoc. See log for details.
thanks
XD
np ๐
that doesnt look like IntelliJ
I cant help you with that
With Eclipse you should not be setting javadocs manually
Unknown javadoc format for Player {key=Lorg/bukkit/entity/Player;} [in Player.class [in org.bukkit.entity [in C:\Users\topic\OneDrive\Desktop\files\dato\server\jars\spigot-1.12.2.jar]]]
error log
Probably because you are in OneDrive. Never a good thing
how can i not be in onedrive?
don;t do it on your desktop
wdym
the desktop folder is in only onedrive folder as far as i know
HOW
I dunno it just works
All my projects are in the OneDrive folder and IntelliJ seems to handle it just fine
dont factory reset
Why not
theres a 50/50 chance that you lose the data inside your onedrive regardless if you login to your microsoft account after factory resetting
Fuck onedrive

Onedrive stinky
Just use google drive
The desktop app syncs your folder and gives you a virtual network disk that lets you use files from other computers directly
intelliJ says that ShapedReceipt is deprecated, but whats the newer version of it? or can i just ignore it?
Javadoc should tell you
Mhm
what have i done wrong
how to get the "plugin" in a seperat class? NamespacedKey key = new NamespacedKey(<???>, "emerald_sword");
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ah thx โค๏ธ
is it normal that a custom receipt isn't shown in the receipt book? or do i need to do smth that it appears there?
ah oke, so how to unlock if the user has a specific item in his inventory?
Vanilla does it through hidden advancements
is it possible to make it a default, that the receipt is unlocked for every player?
let them discover it on join ig
hey guys, this is my first time ever programming a plugin but for some reason when I put the version in the dependency part, it say's that it's not found
I've literally just copy and past the code in the spigot maven topic
Click on the maven symbol on the top right
Tha fk? Did you install maven on your pc?
Intellij comes with maven bundled
yep, but I will try to reinstall
Change the maven home dir in your maven settings and select a maven bundle (v3)
how to read a namespaced key out of the plugin? like i created one at the receipt and now need it to give the player the receipt
okay
Also one thing, I am using the java jdk 19 (if i am not wrong), do this affect this?
Does bukkit runnables lag the server once theres a decent amount
Or when does it start to lag the server
Create a variable and pass it around or create the same key again
because I've following a tutorial and the guy it's using the jdk 1.8, i've just notice this now
When the runnable does something heavy then even one runnable can lag the server
True ig
soooo... i got to pass a variable out of the receipt creator to the listener? o.0 no easyer way?
Managing runnables is quite painfull. I usually just create one runnable and add tasks to it to work on.
Then add another runnable for other types of tasks.
This is as easy as it gets in java... You can also make it a constant. Or create a factory.
I've been diagnosed with habba ๐ญ
Sounds like something a baby would say right before the spoon hits
didn't even need to do that, I've just created a new project and it worked
for some reason
could you explain how to do? cause i don't get it ๐ญ
How can I store a list of objects in json with gson?
Just throw it in
I only know how to store one object,
A list is an object
You need a TypeToken for that. One moment ill show an example
Kk
List<String> inputList = List.of("Foo", "Baz");
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String json = gson.toJson(inputList);
Type token = new TypeToken<List<String>>(){}.getType();
List<String> outputList = gson.fromJson(json, token);
But you should generally not have a need to manually serialize collections like that.
I see
very peculiar
String json = gson.toJson(inputList);``` This part is writing?
and the below is reading
Yes
Thank you 7
was confused by the question at first XD
Im planning on storing around 100-200k documents with around 20 variables in each. Im guessing I'll be totally fine. But im just going to make sure
I mean you can probably get a rough calculation if you know how much space each variable uses.
Just store 1 document and make 200k of them
500 MB is huge amounts of storage if spent wisely
I think we good
Around 40 bytes per 20 characters in a variable
So just 40 * (10 * 150000)
Which is 60M bytes aka 60MB
Around 833K variables give or take since some will cost more storage than others
I think im good xD
Hey so trying to make a code that places blocks behind an arrow, but the blocks just gets placed inside of the arrow and then it stops. Looking for something that can delay the block placement
?scheduling
It's pretty easy, what are you having issues with?
can someone walk me through how to module your project with maven I don't really get how it works i kept getting errors last time trying to do it. I'm trying to submodule my project because of NMS versions
how would i change the location of the compile jar in maven?
I think I figured it out, but dose this work??
public void BlockBow(EntityShootBowEvent s) {
new BukkitRunnable() {
@Override
public void run() {
Entity arrow = s.getEntity();
if(arrow instanceof Arrow) {
Location loc = arrow.getLocation();
if(loc.getBlock().getType() == Material.AIR) {
loc.getBlock().setType(Material.GOLD_BLOCK);
}runTaskLater(plugin, 30);
}
}
}.runTaskTimer(plugin, 0, 0);
}
With the runtasklater?
@hasty prawn
Sorry if its not allowed to ping
You would need another BukkitRunnable if you want to schedule 2 tasks like that.
you get the entity which used bow, not the arrow itself
e.getProjectile() returns the arrow
Thanks
So this wont work?
public class tutevents implements Listener {
Main plugin;
public tutevents(Main plugin) {
this.plugin = plugin;
}
@EventHandler
public void BlockBow(EntityShootBowEvent s) {
new BukkitRunnable() {
@Override
public void run() {
Entity arrow = s.getProjectile();
if(arrow instanceof Arrow) {
Location loc = arrow.getLocation();
new BukkitRunnable() {
if(loc.getBlock().getType() == Material.AIR) {
loc.getBlock().setType(Material.GOLD_BLOCK);
}
}.runTaskLater(plugin, 33);
}
}
}.runTaskTimer(plugin, 0, 0);
}
}
I think I got it
Honesly thought schedule was so hard
and you messed it up
still messed up
Added the public void again
@EventHandler
public void BlockBow(EntityShootBowEvent s) {
new BukkitRunnable() {
@Override
public void run() {
Entity arrow = s.getProjectile();
if(arrow instanceof Arrow) {
Location loc = arrow.getLocation();
new BukkitRunnable() {
@Override
public void run() {
if(loc.getBlock().getType() == Material.AIR) {
loc.getBlock().setType(Material.GOLD_BLOCK);
}
}
}.runTaskLater(plugin, 5);
}
}
}.runTaskTimer(plugin, 0, 0);
}
}
Actually kinda works
But getting lower fps for a wierd reason
every tick you are scheduling a new runnable to run in 5 ticks time
@EventHandler
public void BlockBow(EntityShootBowEvent s) {
Entity entity = s.getProjectile();
if (!(entity instanceof Arrow arrow)) return;
new BukkitRunnable() {
public void run() {
if (arrow.isInBlock()) this.cancel();
else {
Location loc = arrow.getLocation().clone().subtract(loc.getDirection().normalize());
if (loc.getBlock().getType() == Material.AIR)
loc.getBlock().setType(Material.GOLD_BLOCK);
}
}
}.runTaskTimer(plugin, 1L, 1L);
}```
he needs it every tick
he's creating a trail of blocks everywhere the arrows goes
yep
you also need to cancel the timer when the arrow dies
Should I just add remove arrow or something?
or dosent that work?
Ah okay that makes sense
Thank you so much guys
Feel like I have learned so much
It just says Free java lessons
idk if subtract part works but you need smth similar
yeah
Soooo how do I get them?
xD
it's 1:56 for me
so after sleep
Yeah sure
we could do smth
But one last thing
Getting error on if (arrow.isInBlock()) this.cancel();
isinblock
if (((AbstractArrow) arrow).isInBlock()) this.cancel();
no
that's just Arrow class
i changed it different way
use it instead
so you don't do class cast everytime
what would be the best way to store player cosmetics (with different categories) and what they select
mysql
a good way then
if you have many values just don't use yaml
cuz if file size gets too big YamlConfiguration.loadConfiguration() goes brrt
and dies
If you want to have 2 columns(player, cosmeticId) just use a small sql table then
or use a lot of small yml files for each player(see no real need in this)
but they can own more than just 1 cosmetic
can you store an array in there?
oh wait i could store a string
that is like
cosmeticID,cosmeticID,cosmeticID,cosmeticID,cosmeticID
etc
and do string.split(",") or something
and then a mysql thing of all cosmetics
or yaml file actually
to store what item the cosmetic is
Create a table for cosmetics with owner ids
| ID | owner | cosmetic |
___________________________________________________
| 01 | DDA4-UI33 | Wings-A |
| 02 | DDA4-UI33 | Walk Trail |
| 03 | KN9K-F099 | Wings-A |
This is the correct relational approach
oh?
but i would have thought that each cosmetic type would have its own id
rather than who owns it
the string.split methods sound fun too xD
and their id
like each item has its own id, rather than each instance of a player owning an item
each cosmetic of same type?
what's the pros and cons of each?
yes
how would i fix this?
Exception in thread "cluster-ClusterId{value='6336287dfe350b564eed7153', description='null'}-ac-itkzscn-shard-00-00.gdgktnz.mongodb.net:27017" java.lang.IllegalStateException: zip file closed
well for string split you need to get value from db
if does not exist store a new one
if extists add new value to the string you got and store it again
and this
You have a "one to many" relation. So if you use a relational database and not a document one like mongodb then
the correct way is a separate table with one entry for each cosmetic with its owner.
com.mongodb.MongoQueryException: Query failed with error code 8000 with name 'AtlasError' and error message 'user is not allowed to do action [find] on [database.collection]' on server ac-itkzscn-shard-00-02.gdgktnz.mongodb.net:27017
because mongo is being weird
Dont reload
ever
guy got zip file error
that gay
based
how would i fix this tho, it does have the permission
it should anyawys
Use the right mongo credentials
And dont reload. The message even tells you that it causes bugs.
well basically don't leave your connections opened and so on
its because the plugin disables
because mongo is being gay
but how do i fix that second error
credentials are correct
i triple checked
This can happen if you have a user that only has permission to a certain database but you do not include this in your connection string. E.g. the connection string atlas will recommend is
mongodb+srv://:@productive.abcd.mongodb.net/?retryWrites=true&w=majority
but if your user only has access to the database "my-database" the connection string should look like this
mongodb+srv://:@productive.abcd.mongodb.net/my-database?retryWrites=true&w=majority
i fixed it
we good
thanks
also, im wanting to make a collection per server
how would i do that?
i could do the server name
but if they change it, it'll break
The plugin users should manage their own databases
alr
Would HumanEntity.getInventory().getItemInMainHand() be null if no item is held or an item with Material.AIR, and does the same got for .getEquipment().getHelmet()?
how would I prevent arrow pickup?
declaration: package: org.bukkit.event.player, class: PlayerPickupArrowEvent
I figured it out, it's Material.AIR
Right now I am working on an item that you activate and deactivate by right-clicking and delete by dropping. Also, if the item is active, it should not be dropped. I am running into an issue though because apparently the PlayerInteractEvent gets fired when you drop an item while looking at air. This means that if the item is active it will stop the item from dropping, but it will also deactivate the item. The DropItemEvent fires first, so what I am thinking is to time stamp the DropItemEvent, put the timestamp into a hashmap, and cancel the PlayerInteractEvent if it is within a fraction of a second of the drop event. Is that the best way to do it though, or is there a better way to solve the issue?
AFAIK, the PlayerInteractEvent does not fire if you drop an item. That's what the purpose of the PlayerDropItemEvent is for. You should be able to listen for both events. In your PlayerInteractEvent handle the item state switching. Then in the PlayerDropItemEvent just check to see if the item they dropped is in the active state and if it is, cancel the event.
can someone help me modify the loot table of a player and natural chests
to buff it
like the luck effect but actually does something
For PlayerChangedMainHandEvent how do i get the old item?
This event is for when a player changes their client settings to display the hand of the player either on the left or right side of the game.
oh
The event you're looking for should be InventoryInteractEvent
isnt that for like clicking on the inventory?
That includes their own inventory.
ok leme try
You sure they're not looking for PlayerSwapHandItemsEvent?
I.e, when they put something in their offhand
How did I miss that in the docs ๐ข
Lol, it happens
how does hypixel do their first person view thing?
where you can look into the eyes of other players as spectator?
do you have a video of that?
uh no
Player#setSpectatorTarget
no
as i was saying, it's a relatively small feature so nobody really makes video on it
put the player in spectator
no
cringe
i use my own spectator system bruh
cringe
Well, then idk what to tell you.
hide them?
are you stupid
genius
we cant help you without knowing what you mean
oh my god i'll get a video
ik what you mean
Bro is pressed ๐ญ
there
this is some random person i clicked on
when i died
Yea, thats spectator mode.
no
it's not
u have a hotbar and a character
a hot bar with items
oh wait
actually
i think they put u in spectator mode
that's smart
no shit
and then take u out of it
to do normal spectating
normal spectating: flying around in survival mode with invis and stuff
first person spectating: spectator mode
but how would i keep track of when they exit the first person view?
They use Sneaking
iirc
is there a packet i would listen for?
An event yes.
what is that event?
i need a plugin to whitelist players from discord
?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/
so there def. no way to spawn the beams from guardians via the api right
I guess other than spawning an invisible guardian for these purposes
Then you need a plugin and a discord bot.
yeah
Do you understand the problem
I am having some pretty hardcore code rot issues
ow
I was abusing static back in 2017 (tbf it made sense back then) and now it has come back to haunt me
I just rewrite everything
I mean
sort of halfway through doing that as is
what I really need to do is either make some of the core classes cloneable or completely tear it down and rebuild it so they can generate objects I can use
these do some pretty expensive parsing operations and at the scale this needs to run I do not want to redo that every time
yeah think I'll just split the parsing to its own thing and use the parsed data for instantiation
I can already tell this is not going to be fun
I'm rewriting a plugin the second time now, I think this is the iteration I will be able to maintain XD
Maintain what's that. I'm stuck in my rewrite cycle
XD
I've rewritten my forge mod 3 times now
I'm wondering if I should start over again
having learned about separation of concerns and constructor injection, aswell as composition over inheritance I do think its pretty good code for like 1 year of experience XD
fast forward two years, turns out you didn't know anything about inheritance and are rewriting the project to use it way more
except when you dont actually have any reason to use it
interfaces, yes. abstract classes, barely
that just makes my prophecy sound way more sound
why tho
Abstract classes have their use
half the battle is discovering how they can be used more efficiently
welp, I hope I can at least refactor my code instead of rewriting it all
not even half way done and its like 2k lines already
that's not even a rewrite
old code was like 10k, the one before that was 15k
doing the same stuff with less code is good
Magma flexing inefficiency
you're just jealous of how close I am to 69k
we are
Mans in denial
jealousy intensifies
What comments
any way I can optimize this code, it finds the subcommands by looking at the first arg, finding the commands, getting the annotations and matching the arg
public static Class<? extends Command> getSubcommand(Class<? extends Command> root, CommandBuilder commandBuilder, String[] args) {
if (args.length > 1) {
ArrayList<Command> commands = commandBuilder.getCommands();
ArrayDeque<String> argStack = new ArrayDeque<>(Arrays.asList(args));
Iterator<String> value = argStack.iterator();
Class<? extends Command> previousCommand = root;
while (value.hasNext()) {
String currentArg = value.next();
Class<? extends Command>[] annotatedSubcommands = CommandUtils.getSubcommands(previousCommand);
if (annotatedSubcommands!=null) {
for (Class<? extends Command> subcommand : annotatedSubcommands) {
if (subcommand.getName().equalsIgnoreCase(currentArg)) {
previousCommand = subcommand;
}
}
}
}
return previousCommand;
}
return null;
}```
also boy if you thought what I was doing before with the scripts was bad
let me tell you
I am now splitting it up so I can precache the parsing
Sounds like my original plan but with changes
and I'm approaching it with all the finesse of a man with a chainsaw and about 5 minutes before they get to clock out
Sometimes I want to have good nights of sleep and then you ping me with some code
look at how beautiful it is
This is exactly what I wanted to avoid
That if check on the default param because you couldn't bother making an empty block of code
It's gonna be a long day today I can feel it
the if check is pointless
it's an action that just runs the additional scripts, and every action does that as well if any exist
then I probably messed up my switch syntax then
I just didn't want console telling people the action was jacked up when it's just not meant to do anything
presumably @echo basalt prefers this far worse solution
which actually I should be able to delete now
I think
wait no never mind I can't
jesus thats a lot of cases
I mean not really
anyone who has ever done complex stuff with mc materials has probably written switch statements 3-5x the size of this one
not that bad
its nearly as many cases of beer I got in the back
this is what switches are meant to do after all
just think you could some register and handle thing
register cases in a class and then handle them elsewhere, might be neater
it takes more time and ultimately you write more
and makes it harder to find what you're looking for
what's not to like
but if you need to change something specific you know where to find it
good luck remembering the name of every variable lol
well if you need to change something here you just edit the switch
I just think it would be a bit more solid and if you eventually end up with 500 cases, its gonna be a lot easier to manage
some of the people in here have a straight up otherworldly definition of "easier"
future proof then
how is that future proof
how is 500 classes more future proof compared to a 500 case switch
would you rather have 2000 classes or 2000 lines in a switch statement
I never said have 2000 classes lol
then you have failed to future proof
then what did you mean exactly?
if you look at the switch you can see a lot of cases which are very similar
something like this
breaking them up into a few classes each with a switch to handle those specific cases would be good
so instead of a switch, I register each version and its handled elsewhere
oh so I get to still write a line per entry but also I have to manage that entry elsewhere on top of that?
just imagine that comes to 500 lines of switch
kinda, I made a builder, registered each "condition" and then I use a manager that matches each condition and runs the appropriate code
and instead of going through all 500 of them you go through 5 lines and check what you need to edit
and then you only have 100 lines instead of 500 which you need to get through. and edit or change
I mean you do you, I'm just giving you some advice so you don't cry yourself asleep when you have 500 conditions/cases
you realize that in your example I would have 500 lines calling 500 methods that do the same thing 500 times but in their own classes here right
I prefer something like a big switch over a conplicated builder/manager
you are exponentially adding lines and complexity to something that is currently 1 line, 2 if you include the bit where I have to register the field
at this point I assume that the code we dont see isnt actually complex
in a case where each result would be 1 lone of code, making it more complicated than a switch just doesnt make much sense imo
this switch could already be compressed a bit if you grouped cases with the same outcome
none of the cases have the same outcome
like all parseInteger cases etc
talking about this one
if you think its so complicated that its not worth the effort to avoid future problems then I advice you keep on practicing java my friend
tbh we dont see the methods they use and its a lot of the same method now that I look at it
i dont want to complicate code for the sake of making it more complicated
all values are assigned to their own variables
yeah u right, I wasnt looking at it correctly
youre reading values from config?
mostly yes
that makes a little more sense then
not sure if its possible in your case but I use ConfigurationSerializable for my plugins
I see, it would be ridiculous to create a complicated structure to read some files
File reading is fine I guess, especially if that scale will stay constant.
I also don't understand why so many people don't just ask what the final scope of the system is
I'm already nearly done with all the actions I'll ever want to add
it's 17 lines right now, it might be 30 by the time all is said and done
30 cases is nothing on a switch statement
wasnt looking at it properly, I was thinking that you had a specific method for each case, which isnt so. if there was a specific implementation for each case a class to handle it or something would be good
The problem was that the picture didn't exist because it was deleted
not if its just 1 function per case, making a class for each would be overkill then
can we agree that 30 methods in one class would be badly maintainable, especially if they are more than 10 lines each?
just grouping them roughly would help out, not 1 class per function but one class per like 5 or so
Very much depends on context
I mean only if it makes sense to do so, not just arbitrarily
at least they are using a switch statement and not if statements
The classic agreement is that a class must only have one major reason to change (formally known as single responsibility principle)
Then we have that a function must only do one thing, which is defined as when you cannot extract another function from your given function
However there are some contentions against these classic principles
grouping by default is not arbitrary imo since you have to have something to group by
usually
such as debugging and fixing code
at least thats my philosophy
Well if the code hinders you from being able to properly extend, modify, debug or test it then the code must be poorly written to some degree
Needless to say, switch statements/expressions are convenient but they are sometimes seen as evil
for no reason other than looking repetitive
For one, switches tend to do more than one thing
switch statements give me Vietnam flashbacks
yeah, my mistake was not actually looking at what was happening and just thought "Big switch, bad"
a switch is just a concise chain of command
Also switches sometimes imply your class is a dependency magnet which is usually something you do want to evade if possible
this is one two occurrences of me using switch statements in my code
Myeah thatโs probably more fine
Although pretty useless
We have TimeUnit to convert between time units
i also use switches in my Command classes
Mhhheh, might be fine
ffs I didn't know about that
stackoverflow told me to use spring
Lol
noone ever taught me another way
It works
please
wdym
i wont make a class for every single command argument if thats what you mean
But mapping arguments is usually a better design choice overall
then teach me something better
use a command manager or make one
For all literal sequences you have a sub command class
And then arguments are just arguments
Parse as per usual
most command executions are not more than 5 lines, including player checks
/somecommand epic dodo 4
epic dodo - literal/subcommand identifier
4 - argument
somecommand - main command
yeah I dont see the benefit of this
this will just add like 8 more classes to my code for not much reason
This might help you understand it as well https://www.youtube.com/watch?v=WyFN_jTS4nU
In this episode, I show you how to make a Command Manager for your Spigot plugin to easily manage sub-commands. This will make your life much easier, trust me. I will apply this concept to the Quarter Master plugin, next episode. #Spigot #MinecraftPluginDevelopment
Code: https://gitlab.com/kinglydeveloper/command-manager-spigot
โญ Kite is a fre...
^ especially if your command class does a lot of different things
you will need to make it better than the one in the video tho, because it ain't great
