#development
1 messages · Page 7 of 1
@robust flower anvils?
dragon eggs (?)
note that anvils can also break when on top of non-full (surface) blocks such as slabs or lilypads
the event name 😢 ?
not sure
not important
this is much more than i thought lol
I love how simple this is! 😄 kill me
I just realized tonight that you can do switch expression variable initializations in Java 😂
Was on Java 8 for too long and then went to Kotlin
Switch expressions 😌
So I am extending an abstract class and I have this method ```
@Override
public void join(Player player) {
joinPlayer(player);
}
Is there a way to somehow call joinPlayer (which is also a method in the abstract class) every time join is called instead of having to manually call it in the child class like this?
I am basically trying to create some default functionality alongside whatever the dev wants to add later
well whenever a method is overridden, you lose the default behavior as long as super.<method>() isn't called
😌
ops, sorry for the ping, forgot to turn it off
is it possible that generating only for example 8 chunks with vanilla word generation and anything else is just air
like can i achive this with a plugin or need to make changes in server jar
its like skyblock generation actually
i guess thats works too
so you wouldn’t be able to prevent block generation on the first run because the world is generated before the plugin is initialized. but, i did see someone delete chunk files
you could also just use worldedit if u need to do it once
i can make it once but it needs to be like unlimited* amount of that chunks
i also need to change the world generator to make it only a specific biome etc etc
i don't really know where to start
Create void world, select chunk, create chunk generation, load chunk.
Also if you're trying to do this like skyblock you're gonna need a method to get a new location somewhere in the world.
Easiest would be checking if x >lastX z<lastZ and so on. I think bentobox uses this check if you want to look at their code it's open source.
is it possible to load only a chunk with a worldgenerator
like there will be a space between them
I'm sure you can set a chunks generator and run chunk regen. (I could be wrong though. Testing required.)
is there an event for checking when the placeholder value is change in PlaceholderApi
no
PAPI is entirely based around polling the value of a placeholder, it's more of an "evaluate this expression" kind of thing
@kind granite thoughts?
What do you want to track though?
You’re probably better off checking it from the original plugin or just regular events instead of checking when placeholders change
yes but if there is an event for it, i can do just check the placeholder change event instead of checking every plugin and get the api from that plugin
Hello, is there a way to edit string of a Component ? i tried to look here : https://docs.adventure.kyori.net/serializer/ but it wasnt sucessful
d;adventure Component#replaceText
@@Contract(pure=true) @@NotNull
Component replaceText(@NotNull @NotNull TextReplacementConfig config)```
Finds and replaces any text with this or child Components using the provided options.
4.2.0
a modified copy of this component
config - the replacement config
.
alright i really appreciated it
is it possible to check if a mob can get to another mob
for example if the zombe is in a 2 block hole the answer is false
if it has a block over it's head and in a 1 block cage
false
but it there is nothing restricting it and if the player were to go afk the zombie could attack the player
the answer is true
i wouldn't know the math fo rthat
search for A* algorithm
i would still check maybe if it exists already in the api
if not ^ is your best bet
https://github.com/domisum/Pathfinding found one implementation in minecraft
might help
Pretty sure the built in nms path is a*
not sure how usable it is from its exposed parts
i think it uses a different algorithm though or rather an edited version of A*
since its uniform cube structure rather than nodes with different distances
Paper exposes a fair bit of the path spigot nada
With nms you can definitely do that though
i mean A* itself is not really difficult to implement
but i am 100% sure that there are some optimizations they did to it since A* itself
is fast but not that fast
But it is still easier to just use the nms pathfinding
for sure
https://pastebin.com/2cFm3heY For some reason this isnt setting/saving to the player config. It can read it just fine
here's the methods i call https://pastebin.com/aHTnExjx
ive been trying to use the spigot/paper docs along with googling what might be wrong but i've had no luck
im not getting an error either, it just doesnt want to set/save even though im using the correct method to do so. at least i think i am
can anyone help with tipped arrow i wanna display item with slow falling tipped arrow
No
call the save method
Quick question, there is the PlayerPortalEvent whoch detects when the players enters the portal, but does that include the animation or not (if in survival)? If it does include the animation, is there an event for when the player "touches" the portal?
PlayerPortalEvent
I am confused now lol
That means PlayerPortalEvent doesnt include the animation?
the animation is clientside only, so id assume playerportalevent fires as soon as you enter the portal
this, it fires when someone touches the portal
like im sure when you teleport its the playerteleportevent
cus it has a teleport_cause of endportal,netherportal, end gateway
Oh okay, thanks a lot then!
is there any way to make the placeholders dynamic?
Like %stats_[arena]%
can replace anything on [arena]
yes - the only thing PAPI checks for is that stats is what you specified
can you give me an example?
uhhh
can you show me your current code first?
and I'll show you from there
i didn't writte anything
please don't angry me
you have a String parameter on the onRequest method
that's everything you have after stats_

that is dynamic
that's too much case
i am bad at explaing
sorry
i want to check stats from players from a random arena
i can't create all placeholders for them
then i want to create %stats_[arena]%
I don't know what method you use to get status from players from an arena
to show a stats from that arena
so unless I know I can't say much besides that params will give you [arena]
all PAPI controls is that first part
stats
if the placeholder matches %stats_PARAMS%, it gives it to your method (onRequest)
ok, i want to create placeholders like ajleaderboard (that is what i want from the start, sorry for bad explaining)
I don't know how your plugin is setup
it depends on each plugin
i have a variable
to get the arena stats
but it is required
the arena name from the placeholder
what is the variable type
int
okay but what variable do you store arena stats in
a value of a config path
How would it be possible to override some methods from a class, keeping the original logic, but also adding some of my own logic?
You can achieve that by calling super.method()
is it possible to call the original method of a class that overrides a method? 🥲
Any reason why error messages in IJ's run "console" look like this? I've never seen this before, and there's no stack trace to go with it
what
no, you can call the constructor of a super.super but thats it
i mean with reflection you can do it
but why though, it feels like your class structure is the issue
Wdym by this?
Just curious
how do you do it with reflection?
like doing super.super.super.super.super.something()
since iirc thats not a thing
If you have like Class2 extends Class1 where Class1 extends Class, you can call Class.super.method() I believe
And super.method() will call the method from the first super class (in this case Class1)
I've tried adding the VM option -XX:-OmitStackTraceInFastThrow but that hasn't changed anything
java.lang.IllegalAccessError: class net.neednot.farmnerf.FarmNerf (in unnamed module @0x7eb66914) cannot access class com.sun.tools.javac.util.List (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x7eb66914 why do i get this in the server
it disables my plugin
ah nvm
i was using the wrong listt
and the ide was using a different java version
That's only for interfaces, e.g. MyClass implements Interface1, Interface2 and both interfaces declare the same default (non-abstract) method but with different bodies, MyClass is forced to implement it because which one would the jvm call? in that case MyClass can do either Interface1.super.funnyMethod() or Interface2.super.funnyMethod()
I don't think it's possible with reflection but it is with MethodHandles, https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#findSpecial(java.lang.Class,java.lang.String,java.lang.invoke.MethodType,java.lang.Class)
ahh, makes sense
is there any way to make the placeholder has anything as params at the end?
that means player can do %placeholder_[anything he wants]%
and the plugin still return values?
PAPI gives you the arguments after the first _ exactly as written
what is the spawn reason of a summoned entity
d;CreatureSpawnEvent$SpawnReason%COMMAND
public static final CreatureSpawnEvent.SpawnReason COMMAND```
When a creature is spawned by the "/summon" command
how can I set a block somewhere in the world without the chunk where the block is to be necessarily loaded by any player?
load the chunk beforehand
doesn't setType (or getBlockAt) already load the chunk?
¯\_(ツ)_/¯
i think it does load tge chunk
If anyone has used the paypal webhook api, any idea why it randomly stops sending events after a few of them failed?
last event sent is from an hour ago
I think it might be a bug.
Anyone know why my error messages look like this inside IJ? This is just the same NPE repeated over and over again, there's no stack trace, and every second character is nonsense
looks like an encoding issue in your terminal, can you print the output to a file instead?
I'd have to catch every error to do that though
fix your code xx
I'm trying 😭
use a debugger and pause on exception automatically :p
passing -Dfile.encoding=UTF-8 and -XX:-OmitStackTraceInFastThrow hasn't helped either
did you mistype encoding in your IDE aswell?
No
I did just try IJ's debugger for the sake of it, errors appear the same
I've set both the console and app charset to UTF-8 and the issue persists
can you use a bedrock edition texture file in java?
are they the same thing?
the proportions and stuff
just a file
not a resource pack
like just the item image
According to this you only may change the format for textures including transparent pixels
https://docs.microsoft.com/en-us/minecraft/creator/documents/convertingtexturepacks
hey guys im getting an error with my plugin and it says could not load plugin i think its my plugin.yml but ill also send my code my YML: name: EventListeners version: '${project.version}' main: me.gielhauglustaine.eventlisteners.EventListeners api-version: 1.19 authors: [ giel1234 ] description: a tutorial plugin on eventlisteners and my code: https://pastebin.com/4pGCfJ3h
What does it say is wrong?
nothing it just says in my console [16:28:34 ERROR]: Could not load 'plugins/EventListeners-1.0-SNAPSHOT.jar' in folder 'plugins'
What does it say right after that
at org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.checkSupported(CraftMagicNumbers.java:375) ~[paper-1.18.2.jar:git-Paper-344]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:415) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:323) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-344]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-344]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-344]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-344]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
unsupported api version
You're trying to use 1.19 api version in 1.18
what does that mean
I don't understand
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Action action = event.getAction();
Player player = event.getPlayer();
if (action == Action.RIGHT_CLICK_BLOCK) {
Block block = event.getClickedBlock();
if (block.getState() instanceof GreenStainedGlass)
if (item.getType() == Material.Slimeball) {
//do stuff
layer Player = Bukkit.getPlayer(giel1234)Player.setHealth(0.0D);
}
}
}
}
}``` shouldnt this make it so that when right clicking with a slimeball on greenstained glass it would kill me? making a deathrun plugin
layer Player
public class ActivateTrap implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Action action = event.getAction();
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (action != Action.RIGHT_CLICK_BLOCK) return;
if (event.getClickedBlock().getType() != Material.GREEN_STAINED_GLASS) return;
if (item.getType() != Material.Slimeball) return;
player.setHealth(0.0D);
}
}
Idk which is your spigot version, but this should work. @granite hound
thanks
I haven't tested this, use at your own risk
Also make sure you've registered your event. Hmu if it works/doesn't work.
ok
do i have to register it in my main or in this class?
Main
also i mod c# unity games and i know you have to call from main is that here too?
You get your PluginManager instance and register your event with #registerEvents(Listener, JavaPlugin);
d;PluginManager#registerEvents
void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin)```
Registers all the events in the given listener class
listener - Listener to register
plugin - Plugin to register
how expensive is the call to this method?
CraftServer#isPrimaryThread
public boolean isPrimaryThread() {
return Thread.currentThread().equals(this.console.an) || Thread.currentThread().equals(MinecraftServer.getServer().shutdownThread);
}
do you mean like this? @Override
public void onEnable() {
// Plugin startup logic
void registerEvents(@NotNull
Listener this,
@NotNull
JavaPlugin ActivateTrap)
hmm, not quite
you need to pass your event (listener) instance (new ActivateTrap())
and for the second parameter you can use this keyword
ok so like this @Override public void onEnable() { // Plugin startup logic void registerEvents(@NotNull Listener (new ActivateTrap()), @NotNull JavaPlugin this)
Still not quite
Bukkit.getPluginManager().registerEvents(new ActivateTrap(), this);```
khem..., ;, khem...
o yeah ok so after that is it good or does it have to be what deerjump said?
Just replace your thing with what @winged pebble sent.
What does that error say?
cannot find symbol
For what
for what you send
Which part
right before the line and before activatetrap
Just show me a screenshot
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.
Can you click here? It should show more text on the right
https://i.imgur.com/1A1iJHB.png
Also... this might not work out
first, can you make a folder: src/main/java (3 folders inside each other) and put ActivateTrap.java in there?
why not?
ok
then try running mvn clean package instead of build
unless that's some IJ thing
if you expand Run Configurations on the right, there should be a button package, press that
what should i select from package?
wdym
what shows up?
Or just double click control and a window should pop up, then type mvn clean package and press enter
its a dropdown menu
now theres even more
one is cannot access me.gielhauglustaine.deathrun.ActivateTrap
that package doesn't exist
so you know the java folder that you just made
that was already there
can you show the whole error?
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
What does the package at the top of Deathrun say
do you mean compile or what do you mean with package?
package me.gielhauglustaine.deathrun;
o ok
o yeah
i didnt add that
ok i fixed that but cannot find symbol stays
You reran the package goal?
I just mean after you changed that file, did you try to compile again
Yes
yeah i did
And you get the same exact error?
not really the 2 other things got removed but all the cannot find symbols still here
You have to be specific my dude
that is the error
it says nothing more
cannot find symbols
is all it says
the other 2 where duplicate class: ActivateTrap error and cannot access me.gielhauglustaine.deathrun.ActivateTrap but those are solved now
So the errors are fixed now?
no not really those two yeah but it still gives 11 of the errors about cannot find symbol
Show your pom.xml
Your groupid doesn't match your package
english isnt native language xd
hasnt fixed it
when editing it did say it wasnt part of the project
i think its in the wrong place
your artifactid should be lowercase as well
didnt work
When editing what?
the pom.xml
It said the pom.xml wasn't part of the project?
Where do you have it?
its in that yellow part at Project
Yeah, it should be at the root
And you clicked the reload button thing at the top right after you edited the pom.xml
?
you mean run deathrun build?
No, when you edit the pom.xml in the top right a little square with a reload symbol should show up
i think i found something
every name of deathrun in pom is still with big letters
or
i did that
didnt fix it
send the pom again
the error is for example cannot resolve symbol bukkit when i go over the word bukkit
Send your whole main class file
import org.bukkit.plugin.java.JavaPlugin;
public final class Deathrun extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
Bukkit.getPluginManager().registerEvents(new ActivateTrap(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}```
where is suggested actions?
When you hover over the error
public class ActivateTrap implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Action action = event.getAction();
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (action != Action.RIGHT_CLICK_BLOCK) return;
if (event.getClickedBlock().getType() != Material.GREEN_STAINED_GLASS) return;
if (item.getType() != Material.Slimeball) return;
player.setHealth(0.0D);
}
}
``` and for this?
Import all the stuff you need to
in main incompatible types: me.gielhauglustaine.deathrun.ActivateTrap cannot be converted to org.bukkit.event.Listener
What Listener did you import
import org.bukkit.Bukkit; i just added this
Okay, intellij will tell you what you need to do
If you hover over the errors, it will tell you what's wrong and usually suggest a fix
how can i find the correct
intellisense is the auto complete suggestions
it works!
I'm getting an Enchantment cannot be null on items that don't get enchants
public class ItemBuilder {
private Material material;
private String displayName;
private Enchantment enchantment;
private int level;
private List<String> lore;
private int amount = 1;
private short damage = 0;
public ItemBuilder(@NotNull Material material) {
this.material = material;
}
public @NotNull ItemBuilder setName(@NotNull String displayName) {
this.displayName = translateHexCodes(displayName, OreNLore.getInstance());
return this;
}
public @NotNull ItemBuilder setLore(@NotNull String... lore) {
this.lore.addAll(Arrays.stream(lore).map(s -> translateHexCodes(s,OreNLore.getInstance())).collect(toList()));
return this;
}
public @NotNull ItemBuilder setAmount(int amount) {
if (amount > 0 && amount < 65) this.amount = amount;
return this;
}
public @NotNull ItemBuilder setMaterial(@NotNull Material material) {
this.material = material;
return this;
}
public ItemBuilder durability(short damage) {
this.damage = damage;
return this;
}
public ItemBuilder addEnchant(@NotNull Enchantment enchantment, int level) {
this.enchantment = enchantment;
this.level = level;
return this;
}
public ItemStack build() {
ItemStack itemStack = new ItemStack(this.material, this.amount);
ItemMeta itemMeta = itemStack.getItemMeta();
if (this.displayName != null) itemMeta.setDisplayName(this.displayName);
if (this.lore != null) itemMeta.setLore(this.lore);
if (this.enchantment != null) itemStack.addEnchantment(this.enchantment, this.level);
return itemStack;
}
}```
Would anyone know how to fix this?
items that don't get enchants say they can't be null
Basically like this:
ItemStack barrier = new ItemBuilder(Material.BARRIER).setName("&cOutput").build();```
use brackets
for?
ifs
readability/maintainabilty, etc
they don't need them, but I can add them
public class ItemBuilder {
private Material material;
private String displayName;
private Enchantment enchantment;
private int level;
private List<String> lore;
private int amount = 1;
private short damage = 0;
public ItemBuilder(@NotNull Material material) {
this.material = material;
}
public @NotNull ItemBuilder setName(@NotNull String displayName) {
this.displayName = translateHexCodes(displayName, OreNLore.getInstance());
return this;
}
public @NotNull ItemBuilder setLore(@NotNull String... lore) {
this.lore.addAll(Arrays.stream(lore).map(s -> translateHexCodes(s,OreNLore.getInstance())).collect(toList()));
return this;
}
public @NotNull ItemBuilder setAmount(int amount) {
if (amount > 0 && amount < 65) {
this.amount = amount;
}
return this;
}
public @NotNull ItemBuilder setMaterial(@NotNull Material material) {
this.material = material;
return this;
}
public ItemBuilder durability(short damage) {
this.damage = damage;
return this;
}
public ItemBuilder addEnchant(@NotNull Enchantment enchantment, int level) {
this.enchantment = enchantment;
this.level = level;
return this;
}
public ItemStack build() {
ItemStack itemStack = new ItemStack(this.material, this.amount);
ItemMeta itemMeta = itemStack.getItemMeta();
if (this.displayName != null) {
itemMeta.setDisplayName(this.displayName);
}
if (this.lore != null) {
itemMeta.setLore(this.lore);
}
if (this.enchantment != null) {
itemStack.addEnchantment(this.enchantment, this.level);
}
return itemStack;
}
}
Wdym
can u show the error?
thats interesting
oh
i fixed it
i put @NotNull before ItemBuilder
public @NotNull ItemBuilder addEnchant(@NotNull Enchantment enchantment, int level) {
this.enchantment = enchantment;
this.level = level;
return this;
}```
and it fixed itself
That's... odd
¯_(ツ)_/¯
since @NotNull isn't compiled into the jar iirc
That wouldn't have had any runtime effect
Lemme change it back and i'll see what it does
alr
You probably didn't rebuild/reload properly in between tests
no clue
oh well
it work snow, thanks for the help
i guess?
weirdness happened
lol
there's one more thing
items can't get multiple enchants?
i need to do a map don't i
ItemStack diamond_sword = new ItemBuilder(Material.DIAMOND_SWORD).setAmount(1)
.addEnchant(Enchantment.DAMAGE_ALL, 5)
.addEnchant(Enchantment.DURABILITY, 3)
.addEnchant(Enchantment.FIRE_ASPECT, 2).build();```
» Give the helpers some details
» Ask suitable questions
» Be polite
» Wait
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.
How would I use this:
public @NotNull ItemBuilder addEnchants(@NotNull Map<Enchantment, Integer> enchantment) {
this.enchantments = enchantment;
return this;
}```
I feel dumb that I'm not sure how to use a map that's inside of a method
I really don't know how to explain it, I hope you guys know what I mean
You store the map as a field and then loop through and add each enchant that's in the map
can you play mp3/wav tracks in minecraft
i wanted to make it so that it plays il vento d oro when you are the last one alive
lol
you can have a hashmap field + addEnchants() method that adds singular enchant just like how u had it but with map.put() instead + loop the map and apply enchant on build()
yes but only with a resourcepack
Hello guys, i've an economy plugin but how can i check if player don't have enough money to buy items from other plugins?
vault
yo , so ive been trying to create something using an external API that has almost no documentation (savage factions) and I have been trying to find a way to find out if the target block is in a Wilderness / warzone chunk
can anyone help the api literally doesnt say anything
Getting the faction
its right there
wilderness and warzone are both factions
so how can i make it only identify wilderness/warzone
nvm
i would assume Faction would contain something to identify it by
i figured out
hey guys i want to make a deathrun game and the trap activator works but i want to make a basic trap that the red blocks dissapear and the green stay so red and green concrete but i want it to only be in the single area is that possible to select a radius or do i have to specify every blocks coordinate? also would it be possible to make it so you can set the traps up in game as the game will have multiple maps
does persistentdatacontainer essentially a multiversion nms data storage api?
pretty sure PDC stores the tags as nbt tags under the bukkit namespace. so if your question was meant to say is instead of does, I guess the answer is yes
yes i was having a brain malfunction after heavy bombarding of nms management
is bukkit's NBT implementation
so the storage is in bukkit data yml or inside the nbt
ohh alr so its still stored in minecraft nbttag
nbt, but you can't edit any tag you want
oh alr got it
it is stored wherever NBT tags are stored
since they're nbt tags
in the end, just with the bukkit namespace
hey guys i have a question i made it so that when right clicking green glass with slime ball it kills you but i want to activate traps but to do that first i need to be able to make it so that they have different triggers so when i click one green glass with a slimeball something will happen but when doing the same but on a different glass its still green glass but just in another place i need something else to happen does anyone know a way to do that?
i would personally write my own events for what you want to do
TrapTriggeredEvent etc
Thanks
https://sites.google.com/site/kssraju/java/design-patterns/listener-pattern if you are not familiar with listener pattern
a small example is above
I do have a question do so how should i make different events for every different trap?
this is a good document. bookmarked
you make a an object
that contains all the information you need with the event
for example
Sorry I meant if I needed to make an event for the different traps
depends, i would make an event for all trap triggers
so you can listen to it
and go like (redblocktrigger -> fire trap)
you can also use the bukkit event system
Ok and the problem is that it should all be green glass but should do different stuff
okay so then you do this instead
So green glass but there are multiple green glasses but they do different stuff
then create a type enum
and make your event object have a field with the type
so you can check what kind of green grass triggered your event
then on your listener
you can go
switch(type)
case ArrowTrap
case FallTrap
etc
or another approach is to create an event for each trap type
so you just listen to ArrowTrapTriggeredEvent
// do logic on arrow trap trigger
probably cleaner
but i would make an event interface that shares the triggering block and such
Ok because the trap types are specified to the area but the traps have different areas in the map too as there are multiple of the same traps but just with other activor green stained glass blocks
Thanks
public abstract class TrapTriggeredEvent {
private final Block triggeringBlock;
private final Player triggeringPlayer;
public TrapTriggeredEvent(Block triggeringBlock, Player triggeringPlayer) {
this.triggeringBlock = triggeringBlock;
this.triggeringPlayer = triggeringPlayer;
}
public Block getTriggeringBlock() {
return triggeringBlock;
}
public Player getTriggeringPlayer() {
return triggeringPlayer;
}
}
your generic trap event
public class ArrowTrapEvent extends TrapTriggeredEvent{
public ArrowTrapEvent(Block triggeringBlock, Player triggeringPlayer) {
super(triggeringBlock, triggeringPlayer);
}
}
a specific trap event
and while listening, you do it bukkit style
public class ArrowTrapListener implements TrapListener {
@Override
public void onTrapTrigger(ArrowTrapEvent event) {
// do stuff
}
}
this is how i would probably do it
@granite hound
thanks
yeah i should change my the code in super() right?
super calls TrapTriggeredEvent constructor there
since the specific event is extending it
you put the shared stuff into the trap triggered event
and specific stuff into the specific events
if you only have a type that changes
ok
between traps and no other info changes, then you dont need the different event approach imho
i would just make an enum in that case
so in trap triggered the triggerblock should be set to glass
no, you are not setting any of those by hand
your producer is creating these objects
dynamically as they happen
ok
no
ok
GREEN_STAINED_GLASS doesnt even exist
its a Material.GREEN_STAINED_GLASS
and a material is not a block
ok because my activator works but currently when you click it with a slimeball you just die
you can do what you want to do simpler with just if else / switch cases
hey to what should i change traplistener?
you code it yourself, code i gave you is not for copy pasting
example is in the link
is there a way to add multiple conflicting enchantment to a custom enchant?
oh can I use a List of Enchantments in conflictWith() method?
umm
conflictsWith doesn't return a list it returns a boolean
you're supposed to check what the other enchantment is and return true/false depending if they conflict or not
also conflictsWith can accept a list of enchantments yes
there's 2 methods
I mean it requires a enchantment and ig it accepts a List of Enchantments as well
1 that takes in just 1 enchantment and one that takes in a list
yea I get it
but that might be just paper actually, not sure if that method exists in spigot
not a problem for me coz I use paper
what's the current most popular version servers are using right now
would it be 1.19?
according to bstats, it is one of the 1.19 versions yes.
1.19 most poular and 1.19.2 after it
got it
another question for config files, would setting to null be the best way to remove it?
pretty sure that's the only way to remove anything in a ConfigurationSection
yes
errr could someone send the link here
got it thanks
👍
what event/events would I use to prevent unequiping armor
curse.ofunbinding
Hey is it possible to detect when a user uses fabric and what mods they use? Or just one of them.
Yes to both
for maven build, is there a way to specific where to install the jar
System.out.println(contador);
contador++;
Thread.sleep(1000);
}```
how do I make so that this statement repeats itself
I add return at the end?
with what parameters
You remove the condition in your while?
wdym
while (contador < 5){
i dont get what you are saying
that will repeat until contrador is 5
what i meant is
i want the statement to repeat itself
ah
im guessing its a method?
try statement
you either wrap the whole thing in another while
or you call the function again
from the function
so it recursively repeats
or just add an
if contador == 5)
contador = 0
lets say its
public void countToFive() {
// count to 5
countToFive()
}
or to be fancy
contador %= 5;
oh no not the modulus operator
oh yes, a terrifying endeavor
only the biggest of brains can handle how it's modulating
thank you
i also added a blank sout at the end
just to make things a little bit less confusing
but
now it's counting only up to 4
what do i do
ill just increase the while by one
now it's working
i'll also avoid asking for help here
does anybody knows what will happen if you try to insert a value in mysql while it's the already exact same thing
what the fuck https://imgur.com/a/5eHMQ4d
you cant insert
if you mean update or upsert then it will replace the old value
yeah but if you try to insert it again
gives exception
if you are not sure if the value will be there
and just want it to be set
then use upsert
that is what i looking for tysm
hey aki in the listener @override doesnt work but shouldnt @override only be used in the main class?
huh
you need to learn some java
override means its overriding a method
that your class is implementing
in this case its overriding the listeners event method
o yeah i found that i accidentally changed it to eventlistener instead of traplistener do i have to make a custom listener?
yes
do you have any docs how?
that doc shows the full workings of listener pattern
@merry knoll
please
what is going on
You sure you don't have the entry point being another class?
hey i have some errors for myeventproducer can anyone review it and help me with it or something ```package me.gielhauglustaine.deathrun;
import jdk.internal.icu.text.UnicodeSet;
import java.util.Vector;
public class MyEventProducer<myEventListeners_> {
private int id_ = 0;
Vector MyEventListener, myEventListeners_ = new Vector();
public void addMyEventListener (ArrowTrapListener listener) {
listeners_.add(listener);
}
public void removeMyEventListener(ArrowTrapListener listener) {
listeners_.remove(listener);
}
public void notifyMyEventOccured() {
int i;
myEvent myEvent = new myEvent(this, i++);
while myEventListeners_.hasMoreElements() {
ArrowTrapListener listener = myEventListeners_.nextElement();
listener.myEventOccured(myEvent);
}
}```
I'm confused, how does Vector play into this?
I got it from a Java docs
Very old
Extremely old
Also those names are extremely cursed
Yeah lol
I actually thought it was a different language at first
There’s no consistency in any of the names either
Could you explain what you are trying to do?
yeah i decided to just use the names listed there to follow better
You don't have a variable named listeners_
Those images have about 2 pixels
im trying to make a custom listener for my custom event
What tutorial are you following?
Yeah this tutorial isn't great tbh
If it's in spigot, you could just use the built in ways
The exact same way that bukkit does events
You just have your custom event that is fired when it happens, and your Listener that works the exact same way as the other events
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class ActivateTrap implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Action action = event.getAction();
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (action != Action.RIGHT_CLICK_BLOCK) return;
if (event.getClickedBlock().getType() != Material.GREEN_STAINED_GLASS) return;
if (item.getType() != Material.SLIME_BALL) return;
new ArrowTrapEvent();
}
}``` should i do it this way?
no not that i know
i mean like i think i dont
but it can be im not understanding
Bukkit.getPluginManager().callEvent(<your event here>)
also for some reason the triggering block and player have private access but everyhting is public in the script its taken from ```package me.gielhauglustaine.deathrun;
import sun.jvm.hotspot.opto.Block;
public class ArrowTrapEvent extends TrapTriggeredEvent {
public ArrowTrapEvent() {
super(triggeringBlock, triggeringPlayer);
}
}```
Show TrapTriggeredEvent
import org.bukkit.entity.Player;
import sun.jvm.hotspot.opto.Block;
public abstract class TrapTriggeredEvent {
private final Block triggeringBlock;
private final Player triggeringPlayer;
public TrapTriggeredEvent(Block triggeringBlock, Player triggeringPlayer) {
this.triggeringBlock = triggeringBlock;
this.triggeringPlayer = triggeringPlayer;
}
public Block getTriggeringBlock() {
return triggeringBlock;
}
public Player getTriggeringPlayer() {
return triggeringPlayer;
}
}
You have them as private
What do you mean by this
As that's not the right Block
And your class needs to extend bukkit's Event
ok so i changed that but where are they set private?
also where should i do Bukkit.getPluginManager().callEvent(<your event here>)? in my main or in my activatetrap?
When you want the event to be fired
when they right click with a slimeball on green glass oooo
yeah
its the activate
but do i still need new ArrowTrapEvent(); then?
Well as it stands, I see no reason to have that class, it doesn't add anything different than the TrapTriggerEvent
yeah but i still need to do that as some traps will remove blocks and some will make you die on impact etc
also this gives some errors Bukkit.getPluginManager().callEvent(<ArrowTrapEvent>);
Does anyone know if it is doable to store T as a variable in Java?
I currently have this method:
public <T> T getFavicon(Function<BufferedImage, T> function) {
return function.apply(image); // image is a BufferedImage instance
}
And I want to change it so that it would return T directly if it already has made it before.
Like something similar to f.e.
public <T> T getFavicon(Function<BufferedImage, T> function) {
if (cached != null)
return cached;
return (cached = function.apply(image));
}
yeah, you just have a field as type T
public class Example<T> {
private T myThing;
public T getThing() {
return myThing;
}
}
Where does T come from?
Like what will define what T is
i still get an expression expected
What did you change it to
Bukkit.getPluginManager().callEvent(ArrowTrapEvent);
You have to pass in a variable
just watched a java tutorial and I didn't really understand. Can someone help me understand this code? please ```class theThread implements Runnable{
String name;
Thread t;
theThread(String name){
this.name = name;
t = new Thread(this, name);
System.out.println("Created New Thread: " + t);
}
public void run() {
try{
for (int i = 5; i > 0; i--){
System.out.println("Thread: " + t + " " + i);
Thread.sleep(1000);
}
}catch (InterruptedException e){
System.out.println(e);
}
System.out.println(t + " is existing.");
}
}
public class creatingMultipleThreads{
public static void main(String[] args){
theThread theThread1 = new theThread("thread1");
theThread theThread2 = new theThread("thread2");
theThread theThread3 = new theThread("thread3");
theThread1.t.start();
theThread2.t.start();
theThread3.t.start();
}
}```
also @winged pebble if i do it from activatetrap would i still be able to make it so on some green stained glasses when clicked with slimeball it activates a arrowtrap but then on another its for example a parkourtrap?
In my case is it just in the function itself and is defined by whatever the function would return.
because now it activates it when pressed with a slimeball but i want the same to be done but have a different result depending on what the glass should be assigned too
I chose this as it allows me a single method to convert a BufferedImage to any Favicon object using their factory methods
i dont think so do maybe that was why the 2 other scripts where needed?
Well I don't really understand your scenario tbh
bump
like this event ArrowTrapEvent = me.gielhauglustaine.deathrun.ArrowTrapEvent;?
Well if you want to implement a cache system, then you'd need to pull the generic out to the class level instead
As the type is no longer determined by the input to the function
do you know the minigame deathrun previously seen in the hive and now only on bedrock?
I highly suggest you look into some Java tutorials btw
ok
There are a lot of things you're messing up on by not knowing java/oop basics
Let me see if I understand what you are trying to do
You want to listen for when the player uses a slimeball on a block, depending on the type of block, it will create a certain type of trap?
nope
its the same block and the same item but a different type of trap
How are you going to differentiate what kind of trap they are trying to make?
the glass is in front of the area where the trap should be
i was thinking of connecting them
i was the one that gave him that code as example
Okay, so basically what I said, but slightly different
yeah
idea was that he would extend the generic event with the different trap types
because i also need to set the areas that the trap cover
also btw thanks a lot for helping
Well you're going to have to use the interact event to determine which kind of trap they are making
I don't see a lot of benefit in making an event for the creation of the trap though, as interact pretty much does what you need
i would personally just make different trap events and fire them as needed
I don't see the benefit of that
The interact event is going to do all the heavy lifting

The interact just says oh, you want this type of trap boom it's made
stay away from threads
until you have a bit more experience
Whereas creating a separate event to fire just creates another step
getting into concurrency will just make it mroe confusing
threads arent that hard
I managed to do somethings with it
concurrency and thread safety is
i highly doubt you managed to cover for race conditions
but I don't understand how that code works
whats that
im just watching the playlist in order
not skipping anything
when you have multiple workers
editing a variable becomes an issue
since its state is not guaranteed
translation is
yeah but the problem is that there will be multiple maps and there will be multiple of the same trap in the same map so it would be nice to make it be simple to set up what the area of the trap is with worldedit or some other plugin or something so you can link your trap area you selected with a green glass or something?
lets say you got an int a = 0
and you have two threads increasing its amount by 1
1000 times each
at the same time
you would normally expect the end result as 2000
but you will get a number between 1000 - 2000 each time
I mean, if that code is straight from a tutorial, I've got some issues with the tutorial
for this code
Yeah, some weird things in it tbh
actual thread safety is incredibly difficult and anyone that says otherwise is either stupid or lying
this
your first class is expanding runnable
meaning that it is a class with a function in it
Yes
a function is?
public void run() {
}
thats basically a function?
yes
that is a function
just a method
what an interface does
a method is a function that belongs to a class
is define a default template
okay, then thats basically it
t is the Thread
it is the field inside of the class
yeah
its a thread
ok
or worker usually
class theThread implements Runnable{
String name;
Thread t; // <--------
// ...
}```
hey do i got a question is this super hard to pull off or is it doable?
why does theThread bother you
class names always start with upper letter
That depends on experience tbh, it is doable though
i mean you are the one thats gonna struggle to debug
with stacktrace
so up to you honestly

It just makes it easier to read code faster
how does it have access to other threads
It doesn't
how does it know
ok because im going to work on my java better but i plan to do this after i got this pulled off as its not that much anymore besides that and i want it off my mind
what other threads are doing
then how
its your job to make sure that they are synched properly
They are all acting independently of eachother
otherwise they write over each other
Created New Thread: Thread[thread2,5,main]
Created New Thread: Thread[thread3,5,main]
Thread: Thread[thread2,5,main] 5
Thread: Thread[thread1,5,main] 5
Thread: Thread[thread3,5,main] 5
Thread: Thread[thread2,5,main] 4
Thread: Thread[thread1,5,main] 4
Thread: Thread[thread3,5,main] 4
Thread: Thread[thread1,5,main] 3
Thread: Thread[thread2,5,main] 3
Thread: Thread[thread3,5,main] 3
Thread: Thread[thread1,5,main] 2
Thread: Thread[thread3,5,main] 2
Thread: Thread[thread2,5,main] 2
Thread: Thread[thread1,5,main] 1
Thread: Thread[thread3,5,main] 1
Thread: Thread[thread2,5,main] 1
Process finished with exit code 0
this is the console
yeah so what?
each thread only prints its own name
it doesnt interact with the other threads at all
i doubt that
eh
Normally, code executes from top to bottom, when you introduce concurrency, you start to have branches
in modern java you dont tend to use the Thread class directly anyway, there are much more modern patterns for handling concurrency
threads are extremely useful, but you need to know what you are doing
hey should i use worledit or some other plugin like a flags plugin or something?
is this where i say kotlin coroutines
what does target: this mean?
context?
but unironically yeah coroutines are a good pattern for managing concurrency
this.name = name;
t = new Thread(this, name);
System.out.println("Created New Thread: " + t);
}```
this constructor
this refers to the instance
that you are firing the code in
so its the instance of theThread
yes but its an instance of an object
instance of a class*
^
🤓

So basically it's just passing itself into the Thread
its an extension
It is a separate language built on the JVM
lol
oh god
so its not java
kotlin is another language
yeah fuck kotlin too
that has cross compatibility with java
its a language that compiles to java
grab the no kotlin spray
i will go and eat popcorn with my coroutines
also i got a question why does everyone hate kotlin?
never used it
have heard of it
they dont really hate it
it's a meme
^
o ok
its way better than java
the amount of publics and statics i avoid typing
companion object 🤓
just object usually if you want static access
just RIIR!
hey what you guys think i should use? i think either worldguard or standalone fawe/worledit
worldedit is the de-facto standard
t is a thread, yes
okay best way to explain is this
you are creating multiple workers
that do stuff on their own
did discord crash or was that my internet lmao
nope
that was me too
anyways
thats usually what a worker do
then you print a number from each
discord bad
which is fine since as you can see the number is exclusive to one thread
also how do you import a reference in intellij?
import a reference?
also fawe works too right?
huh?
dependency you mean?
yeah
fawe i would stay away from
sorry visual studio c#
it multi threads world edit
i mod slime rancher
without giving any flying fucks about thread safety
ok ill just use normal worldedit for making the areas
rust have fearless multi threading!

what is t.start btw?
it starts the worker
and why is our variable t in the middle of it?
you are telling the worker go start working
move your lazy ass and run the code
yes
i think to start the specific worker?
threads are simple when they are contained
bro weve said about 10 times that they DONT interact with each other
they are all completely separate "processes" in this case
since that code is using the thread inside the runnable its making it confusing probably
basically you give the thread a runnable (aka a task)
and it runs it
also i have this event ArrowTrapEvent = me.gielhauglustaine.deathrun.ArrowTrapEvent; for this Bukkit.getPluginManager().callEvent(ArrowTrapEvent);
i think i have to give you an actual use case
so you get why they are used
lets say you have a game and that game needs to get data from the web or a database
do you understand oop?
what the fuck is an oop
object oriented programming
you should get a grip with that before even attempting thread stuff
i tried saying you need oop first before jumping into threads but they seem a bit focused on threads
Im learning java
of course
you really dont need to worry about that shit rn
event ArrowTrapEvent = me.gielhauglustaine.deathrun.ArrowTrapEvent;
I can't think of a way this is valid code
yeah intellisense said i needed to do that
Object oriented programming, means that most of the things you are going to do revolve about objects you create and then run. Is this correct or im stupid
i highly doubt that
t is the thread dud
they made it confusing for you
since they combined runnable with the thread
a thread takes a runnable and runs it
your runnable class has the thread thats running it
as a field
thats it
well it did event ArrowTrapEvent but it has to equal something right?
https://imgur.com/a/d1yrPGV BUT THESE are different THREADS
yes
yes
they are different instances of theThread class
yall did not respond
what else do i need to learn
what should i change it too?
okay you basically need the grasp the idea
around instances
objects
when you use the keyword new
right? at this point i dont even know anymore
you create a new instance

