#help-development
1 messages ¡ Page 1352 of 1
mine seems to be completely reliable
Isn't there a paper implementation for this event
I have tried to break it in every way I can
@quaint mantle This is the string that it gets location from
horrendous
Depends how you detect it
I find the best method is using the StatisticIncrementEvent
what
should I just save x y and z?
Location location = config.get(akfaskl;fkasldkadk)
you literally have the entire location saved
Isn't location by nature config serializable
becaue I cant' teleport someone to something that isn't a location
@rugged topaz sry for the ping, but im getting a massive error in my playermove event, that i didnt have before
here it is
YOU literally have the location saved
so that code that i showed u is supposed to make it into a location
@quaint mantle what did I do wrong?
yes you can
lemme try the plugin and illt ell u if its there
It is indeed config serializable
My guy is splitting string when he has the entire Location saved
Bukkit.getOfflinePlayer(player)
^
tysm
@quaint mantle I am trying to get location values from a book. But to put them in a book I have to use a string. to get the data out of said book I have to convert it back to location. I can't save location data to a book if it's not in the form of a string
Does every class get executed when plugin is running? đ¤
I am trying to figure out how to call my object declarations etc.. if that makes sense
yanlol that was the error
right when i moved on the server i got like 50 of the same errors like that
I mean, the classes that are used get executed
It won't just magically execute classes if you don't interact with them somehow
@rugged topaz should i do it?
How do I use a class on plugin launch?
Well, I don't see any scheduler so it will be hard to know why it does send it every 30 seconds instead of 60
what is player
the scheduler is in a different class
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
spawner.spawnCheck();
}
}, 20, 600);
there's also a version for a name @silent vigil jus so u know
It does run every 30 seconds
(The name one is blocking)
i got it
ty
Yeah bc you have 600 in second param of your scheduler
Yes so every 30 seconds it checks
But if you read what i sent earlier
It should update a cooldown of one minute
and check if that cooldown is up
Well first of all
you need to get long
and not int (from your config)
since it's a TimeMillis
wait theres no . in that is thwere?
I don't think that the whole value fit in an int
arent your symbols turned around
nextBossspawn is always gonna be bigguer than the current time
o
not if the nextBossSpawn is already set
because it's a future time
if it's set then it shouldn't set it again to an other bigger value
what
if(!plugin.data.getConfig().contains("nextbossspawn")) {
plugin.data.getConfig().set("nextbossspawn", System.currentTimeMillis() + (plugin.getConfig().getInt("secondsuntilspawn") * 1000));
return;
}
Nailed it đ
this gives me a list of online players right?
new ArrayList(getOnlinePlayers()) would also work xd
Saves you a stream allocation
Those things aren't the fastes java invention yet
ooh i see
Hello! Okay so I'm working on a countdown thing right, yeah, here it is: https://pastebin.com/bu6gdf8K I do know that its not the most efficient thing in the world but it somewhat works, I just got one problem. The first countdown that runs when the state is IN_LOBBY works fine, but the countdowns for the two other states don't work as the first one. The two others count down 2 and 2 / not every 20 tick. Is anyone able to help me out here?
has anyone been able to get the nice names of advancements? (eg. Isn't It Iron Pick or The Parrots and the Bats) if so, can someone point towards the right direction of capturing those nice ones? i can only grab the namespace
?paste
What doesn't work?
it doesnt detect blocks breaking
theres no console log output
and nothing happens in game
Did you go down the usual check list ? registered listener, @EventHandler annotation
checking that the event actually fires ^^
I am having a problem with some code This is the error: https://paste.md-5.net/fekerocali.bash
and this is the code: https://paste.md-5.net/ocaquyuxec.js
What I am trying to do is get the string data from a minecraft book and turn it into a location variable Here is the data in the book:
Please @ me if responding đ
You should prefer parseInt and parseFloat over valueOf
Lots of issues with that code
Different spacing, pitch missing :, no accounting for newlines
if you have time
are you trying to print out a location because you can do that in one function
Not running spigot
i am running spigot
and I'm trying to get the location froma string and then teleport the player to said location
The stack trace you posted says otherwise
ok
so what changes should I make?
I am kinda new to this
basically it's supposed to get those cords from that book and teleport the player there
For one: your content variable has to be split by the line separation char.
Then each line has to be parsed separately.
ok can you walk me through how to split the content
Its just a normal String#split at System.lineSeparator() or simply '\n'
yea
well I know how i store it
is there a way to just get the specific lines and store them to vars
bc that seems eiser to me
bc I know the line numbers and what they correspond to
No. You get the page as one String. Then you split this String at '\n' which results in a String[]
Doesnt get much simpler than that
sure... but just ask here and someone will answer eventually
Hey, I want to cast Block to Jigsaw after checking that the block is a jigsaw block, but its not letting me cast it (throws a cast error), how can I get my Jigsaw block? Please ping on response
You can either
cast the BlockState of that Block to org.bukkit.block.Jigsaw https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Jigsaw.html
or cast the BlockData of that Block to org.bukkit.block.data.type.Jigsaw https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Jigsaw.html
@lost matrix I split it up by \nl and it works, but then how do I get just one of those lines. For example if I only wanted line 1 and there is 6 lines
thx
super(EntityTypes.ZOMBIE, ((CraftWorld) loc.getWorld()).getHandle());
zombie doesnt like being there
It says it cannot be ZOMBIE cannot be resolved or is not a field
Conclure slow
wat
If anyone know how to use 1.12 nms please dm me im confused
how do you set the minimum amount of blocks in order to take fall damage?
meant to jokingly ping him @ivory sleet slow
Check how far they fell, cancel the event, do whateva u want
doesn't minecraft handle fall damage by velocity not techically blocks?
Itâs blocks
"Check how far they fell" the difficult part
Listen for the damage event and get the fall distance
i'm aware lmao
google suggests to use player#setFallDistance or some other stuff
which doesn't work
It does
It sets how many blocks they have fallen
So setting it to 0 will make them take no damage
Setting it to 1000 will make a big splat
It sets the fall distance
Isnât it meant to be EntityType not EntityTypes?
fall damage
If you want to change that, just use the damage event and some simple subtraction
no
i'd want it to be by default 20 blocks, before the user takes damage instead of the default minecraft 3 or so
yah
i need help w that
The video i was watching said types
but i can try
Wait can someone point me to a good place to learn NMS
Decompiler
- 17 dmg? wdym
20 blocks in order to begin fall damage, instead of 3 to begin fall damage
? one of u r telling me to subtract 17 from the fall distance and then the other from the damage
which
If they fall 25 blocks they normally take 22 damage, subtract 17 and they will take 5
and to know if the player's falling?
Of course you may have to manually account for feather falling
playermoveevent?
Use the damage event
You can get the fall distance and the damage in that event
And do all the maths you want
how to get fall distance
since dmg event
not fall event
i'd need to tell it somehow i'm looking for fall related stuff
player#getFallDistance()?
yeah
You could set the health directly to ignore the armor, and then use setLastDamageCause
And call the damage event manually
Does anyone know how to scan player inventory for an item
Just use a simple for loop over Inventory.getContents
ok
my problem is taht I did that but now I can't get the variable that has the item out of the for loop
Does anyone know how to do that
any reason why player.getWorld().setStorm(true); does not workđ¤¨
You need to set the rain too
strom = rain no?
@young knoll I can't get the variable that has the item out of the for loop
@young knoll ```java
@EventHandler
public void onPlayerFall(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
EntityDamageEvent damageCause = p.getLastDamageCause();
if (damageCause.getCause() == EntityDamageEvent.DamageCause.FALL) {
if (p.getFallDistance() >= 10) {
e.setDamage(e.getFinalDamage() - 10);
} else {
e.setCancelled(true);
}
}
}
}
this should work yea?
setWeatherDuration I believe
Try it
What
in the for loop i stored the item it finds ina variable
Mhm
Not quite
Thatâs called an array
Bukkit.getPluginManager.callEvent
If I make it an array 2 other things get mad at me
ItemStack target = null;
for(ItemStack item : inv.getContents) {
//if statements and what not
target = item;
break;
}
if (target != null)
//doStuff
Or you can modify the item directly inside the loop if you donât need it after
here and to better explain what Coll is saying
if you have the brackets afterwards you have an array
yea ik that
an array is kind of like a list of objects
yea
so you can't just access it like one object
thx for clarification
but the for loop that coll posted will loop through each object in the array
Thx coll
@young knoll ANOTHER PROBLEM yayyyyy
I did what I think u did
if i did it wrong pls tell me
f
k it works thx
@young knoll how would I check if they have a specific item. I want to detect if they have a written book
If itâs any written book just compare material
Hey, has anyone here ever used placeholderapi in their plugin? I followed the steps on their wiki but it didn't seem to work
Itâs per world
Not per player
You can set the server view distance, but you have no control over the players
k
the highest player render distance is the highest server render dist
Kind of
The client will keep chunks past that in memory, but they wonât be updated
where i need to upload the picture of my query?
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/
server.properties
how to find if a player placed an item or clicked in the player's crafting slot"that 4 block in player's inventory!"! i used this
public void onInventoryClick(InventoryClickEvent e) {
if(e.getSlot() == 4){e.setCancelled(true);}
}
```but the crafting table slot numbers are `1,2,3,4` and the player's inventory slot numbers also starts with `0,1,2,3,4...`.now how I find if the player clicked on the crafting slots?
Did you try using the raw slot
Plugins that do this dynamically are useful, try something like view distance tweaks
no wait i will check now
anyone here familiar with uploading to maven central? im running into some issues
thx! đ
So i have this code for a bossbar:
BossBar celebrationBar = getServer().createBossBar("Easter Event!", BarColor.PINK, BarStyle.SEGMENTED_10);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
if(celebrationBar.getProgress() == 1.0) {
celebrationBar.setProgress(0.0);
}
celebrationBar.setProgress(celebrationBar.getProgress() + 0.1);
}
}, 0L, 10L);
And I'm wondering if there's a way to make it visible to all players?
actuall this is also throwing this error:
java.lang.IllegalArgumentException: Progress must be between 0.0 and 1.0 (1.0000000953674317)
max what value
As the trace says, progress must be between 0 and 1
so constrain it between those two numbers
it is though, right?
I have it checking and setting to 0 BEFORE it adds 0.1
use Math.min(1.0, celebrationBar.getProgress() + 0.1)
to ensure it doesn't go above
double/float is not exact so if it is even slightly over after adding as seen in the error, it will cause problems so you need to set a limit
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
if(celebrationBar.getProgress() == 1.0) {
celebrationBar.setProgress(0.0);
}
celebrationBar.setProgress(Math.min(1.0, celebrationBar.getProgress() + 0.1));
}
}, 0L, 10L);
```\
i'd also use >= 1.0 instead of == 1.0, just in case
kk
cool no errors, but how can I make it show up to everybody?
i know that addPlayer exsists, but something like addAllPlayers or do I have to loop through
hell if i know
loop
Hey does anybody know an alternative to saveResource("file.yml", false)in BungeeCord?
@quaint mantle why do you need an alternative?
because saveResource is in spigot but not in BungeeCord but i finded the code.
There is alternatives to it. The method in spigot is just a convenience method for doing such things.
but cool you found your answer
yeah, thank you btw
Hey could somebody help me with Bungee Plugin Message?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
Hello! Okay so I'm working on a countdown thing right, yeah, here it is: https://pastebin.com/bu6gdf8K I do know that its not the most efficient thing in the world but it somewhat works, I just got one problem. The first countdown that runs when the state is IN_LOBBY works fine, but the countdowns for the two other states don't work as the first one. The two others count down 2 and 2 / not every 20 tick. Is anyone able to help me out here?
How do parameters in playing a sound work?
@quaint mantle look at the java doc
Oh God not that again
type in âplaySound javadoc spigotâ on google and itll pop up
@quaint mantle not sure what youâre trying to explain, can u explain what ur end goal is?
The first countdown for IN_LOBBY works fine, it counts 1 and 1 down, but the two others for some reason counts 2 and 2 down or countdown correctly
ty
so the other countdowns go down by 2, but you want 1?
yes
itâs hard to tell what the problem is cus theres referenced code i canât see
like the GameSystem class
honestly if i were u iâd start over and implement a state machine
itd make everything easier to manage and debug
In which way do I use playSound?
anyway your problem is that youâre calling a new Timer within the timer by calling lootPhaseStart
and since youâre variables are static, they are being accessed simultaneously and being decremented by multiple timer classes
oh yeah it was, I'm so sorry for not seeing that
@quaint mantle get a player instance and use playSound
Well I dont know how
why does it have to be world.playSoung(something something..)
why not player.playSound?
it can
it can be both
Ok, and when would a sound list or something show up
look at the sound enum
The world method plays to every player nearby.
The Player method plays that sound to only one specific player.
^
Thats the location a sound is played at.
If the sound is in mono format then the sound will be calculated regarding distance and volume. If its stereo then it will be streamed independent from its play location.
k
Hey just wanted to ask how do i specify subchannel?
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF(player.getName());
player.sendPluginMessage(this, "BungeeCord", output.toByteArray());
getLogger().info("sent");
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The wiki even shows an example of a sub channel
You basically write it as a simple string to the buffer
And then consume it on the other end
i tried but nothing works
like it works but everytime i send it kicks me for this
[AuthToolsBungee] BungeeCord
12:46:35 [WARNING] [P4vlyi] <-> DownstreamBridge <-> [lobby] - EOFException: null
12:46:35 [INFO] [P4vlyi] disconnected with: EOFException : null @ java.io.DataInputStream:-1
You are trying to read froma null stream
or an empty stream and you are not check it for data first
okayy
show me some code (I only just got up)
Unless this is something to do with offline UUIDs
nah its not offline uuid
private void sendBungeeCordMessage(Player player) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("Forward");
output.writeUTF(player.getName());
output.writeUTF("AuthToolsBungee");
player.sendPluginMessage(this, "BungeeCord", output.toByteArray());
getLogger().info("sent");
}
@EventHandler
public void onPluginMessage(PluginMessageEvent e) {
if (e.isCancelled())
return;
// Check if the message is for a server (ignore client messages)
if (!e.getTag().equals("BungeeCord"))
return;
// Check if a player is not trying to send us a fake message
if (!(e.getSender() instanceof Server))
return;
// Read the plugin message
ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
// Accept only broadcasts
if (!in.readUTF().equals("Forward"))
return;
in.readUTF(); // Skip ONLINE/ALL parameter
// Let's check the subchannel
if (!in.readUTF().equals("AuthToolsBungee"))
return;
// Read data byte array
// final short dataLength = in.readShort();
// final byte[] dataBytes = new byte[dataLength];
// in.readFully(dataBytes);
// ByteArrayDataInput dataIn = ByteStreams.newDataInput(dataBytes);
//
// // For now that's the only type of message the server is able to receive
// String type = dataIn.readUTF();
//
// instance.log("got message " + in.readUTF());
// instance.getAuthLocked().remove(in.readUTF());
instance.log("receivedk");
ByteArrayDataInput byteArray = ByteStreams.newDataInput(e.getData());
instance.log(byteArray.readUTF());
}
could you use paste please
?paste
oh okay
its too small in here to read easily, and not static as it scrolls
as you are getting kicked I'm going to assume you correctly registered your receiving event.
pretty sure you don't get to read Forward at all. BungeeCord consumes it
correct, Forward shoudl be auto consumed
i did register it
i do read it?
but you shouldn't
that why you are erroring, you are reading things that are not there
well you need to only read once
oh
Forward and ALL/ONLINE are bungeecord values that you have to specify when you send the message but that are read by bungee
line 17 20 and 21 are all reading
you shoudl be reading once in a while loop that checks for data
so i just need to remove this?
// Accept only broadcasts
if (!in.readUTF().equals("Forward"))
return;
in.readUTF(); // Skip ONLINE/ALL parameter
every time you call in.reafUTF it tries to pull new data
I mean try it xD
okay
that won;t fix it, properly. sec
you are also not specifying ALL/ONLINE at all are you ?
im doing this when im sending it
private void sendBungeeCordMessage(Player player) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("Forward");
output.writeUTF(player.getName());
output.writeUTF("AuthToolsBungee");
player.sendPluginMessage(this, "BungeeCord", output.toByteArray());
getLogger().info("sent");
}
yes but player.getName() makes no sense or am I tripping
like forward forwards the message to other servers
no it does i need the player name
This is the "Forward" code https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward
I don't see the player name in the example on the wiki
i need to get the an player name to the proxy server only
there is ForwardToPlayer
which does take the player name as its second argument
but Forward, as per documentation, takes either ALL or ONLINE as second argument
what is ALL or ONLINE
well first argument
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
read the docs lol
oh okay
I made a server , my friends can join and play normally but if I join, blocks dont drop, mobs stand still , it times me out then my wifi crashes, possible fixes?
Are you a plugin dev?
no
Then you best try in #help-server
oh ok thanks
np
the receiving doesnt work now @eternal night
it just says it has sented on spgiot side but bungeecord doesnt do anything with it
@EventHandler
public void onPluginMessage(PluginMessageEvent e) {
if (e.isCancelled())
return;
// Check if the message is for a server (ignore client messages)
if (!e.getTag().equals("BungeeCord"))
return;
// Check if a player is not trying to send us a fake message
if (!(e.getSender() instanceof Server))
return;
// Read the plugin message
ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
// Let's check the subchannel
if (!in.readUTF().equals("AuthToolsBungee"))
return;
String subChannel = in.readUTF();
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
try {
String somedata = msgin.readUTF();
instance.log(somedata);
} catch (IOException ex) {
ex.printStackTrace();
}
instance.log("receivedk");
ByteArrayDataInput byteArray = ByteStreams.newDataInput(e.getData());
instance.log(byteArray.readUTF());
}
this is bungeecord side
and this is spigot side
private void sendBungeeCordMessage(Player player) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
out.writeUTF("Forward"); // So BungeeCord knows to forward it
out.writeUTF("ALL");
out.writeUTF("AuthToolsBungee"); // The channel name to check if this your data
try {
msgout.writeUTF(player.getName());
msgout.writeShort(0);
} catch (IOException exception) {
exception.printStackTrace();
}
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
getLogger().info("sent");
}
I've never had it work with the "BungeeCord" channel. At some point I believe they added a delimiter requirement so "bungeecord:channel"
i just found out it works but when i try to check for the subchannel with in.readUTF() it returns FORWARD instead of AuthToolsBungee
Thats because its Forward not FORWARD
oh sorry writed it in caps lock it returns Forward only
it shoudl be consumed
out.writeUTF("Forward"); // So BungeeCord knows to forward it
out.writeUTF("ALL");
out.writeUTF("AuthToolsBungee"); // The channel name to check if this your data
ah ok
this is what i send
Not sure what to tell you, that shoudl not be happening
yea
have you tried simply doing nothing in the event and see if it gets relayed?
The javadocs, in true spigot fashion, also don't specify anything about the point at which this event is called
btw you need two servers and two players to test this properly
i have only one server
wot
like one spigot one bungee
Forward sends to every server EXCEPT the sending one
But the event would still be called
yes
but how do i send plugin message to only a PROXY
I'm wondering if thats why its not being correctly consumed. There is no server to send to
i want to send it to proxy not a spigot server
I mean I guess it isn't consumed because you could just not use any of the bungee cord sub channels like Forward or whatnot
and bungeecords logic where it parses Forward + arguments comes after that
Yep, use anthing that is not a preset value
so how do i like send it to only a proxy
You could basically just write out.writeUTF("MyChannel") and out.write(myData)
and then read that on the bungee side
out.writeUTF("ToProxy"); instead of Forward.
or any name you want so its not auto consumed
^ tru
ByteArrayDataOutput out = ByteStreams.newDataOutput();
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
out.writeUTF("ToProxy"); // So BungeeCord knows to forward it
out.writeUTF("AuthToolsBungee"); // The channel name to check if this your data
try {
msgout.writeUTF(player.getName());
msgout.writeShort(0);
} catch (IOException exception) {
exception.printStackTrace();
}
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
getLogger().info("sent");
like this?
yes
okay
you litterally design the protocol however you want and it will send it
if (e.isCancelled())
return;
// Check if the message is for a server (ignore client messages)
if (!e.getTag().equals("BungeeCord"))
return;
// Check if a player is not trying to send us a fake message
if (!(e.getSender() instanceof Server))
return;
// Read the plugin message
ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
//
// // Let's check the subchannel
instance.log("debug");
instance.log(in.readUTF());
if (!in.readUTF().equals("AuthToolsBungee"))
return;
instance.log("true");
and this is on bungeee side
just decode in the same order/fashion at the other end
after debug it should print ToProxy now
omg
if our wild speculations here are correct lul
public void fireGun(FireGunEvent e) {
Bukkit.broadcastMessage("work");
}```
why this event is dont working ?
like a ?
getServer().getPluginManager().registerEvents(listener class, this);
what you mean this
getServer().getPluginManager().registerEvents(this, this);
yes
okay
main class
does your listener have a @brave glenhandler on it?
rip @EventHandler
xd
bye guys
lol
okay? lol
bye son
Any idea why config.set(val, val) isn't updating the config at all?
save it
would it not automatically save when the plugin is disabled?
no
i've decided to experiment with using vscode as a java IDE, im trying to export a jar file using the java projects menu, but it does not compile the yaml files with my jar, but only classes and packages, anyone has an idea on how to fix it?
try put in src folder ig?
You are the only person I've ever met whos is attempting to code a java plugin in VS
xD
yeah didn't work either
ig try putting the yml to src/resources
im just trying to work lightweight btw
Eclipse is lightweight. Visual Studio is... not the best
ig try putting the yml to src/resources
ok did that work?
checking
just asking again if anyone's gotten the pretty names of advancements? like A Seedy Place, Isn't It Iron Pick etc. I can only grab the namespaceid
what do you mean by "pretty names of advancements"?
A Seedy Place, Isn't It Iron Pick, Suit Up, Hot Stuff, etc
?
achievements are bedrock i think, advancements are java. could be wrong
huh
conversely
the name most have changed
achievements are in java
im sure it was called achivements
Thatâs legacy
wait what
oh nvm
It was bumped to advancements
what does the getCriteria() provide you?
btw @latent talon did it work?
nope
weirddd
decompiler shows its in
it needs to be in root
server doesn't recognize it
yeah but if its in root or src it says that it doesnt show
like it doesnt export with it
it didn't show if it was in root or src
I can;t advise you with VS. You need to change its settings to include files in root
yeah thats what im trying to do
ill look in vs code i have it installed so
i'll get back to you on that later đ just finishing up some things
@latent talon try doing your directory as
ă⣠src
ăâă⣠main
ăâăâă⣠java
ăâăâăâăâ dev
ăâăâăâăăăâ cibmc
ăâăâăâăăăăăâ spigot
ăâăâăâăăăăăăăâ blankplugin
ăâăâăâăăăăăăăăăâ App.java
ăâăâăâ resources
ăâăâăăăâ plugin.yml
no
he's just using Visual Studio Code and exporting
i thought about switching
Then donât follow that sourceset architecture
If you donât use maven/gradle
Also yes get an IDE
itâs profoundly more suitable
alright ill get back to intellij
my premium ran out so im just expierimenting with stuff
I mean even eclipse exists
Eclipse + maven is great
yeah i know but eclipse annoyed me when i tried it
Low memory footprint, no subscriptions and does what its told.
Masochistic maybe
Because nano is the best
i literally said im just expierimenting
apart from nano lol
nano op
đ
doron yeah itâs fine but still (;
How would you get the name of an enum if you only have a class of the enum?
Wat
explain?
If you mean the class name just getClass#getName
Ofc it will
idk
No but how are you suppose to get the name from an enum constant if you donât know which one
oop
Or donât have an instance of one
send example
TFW conclure slow
Oh that was the thing I forgot
public enum A {
ABC, CBA, BAC;
}
Class<? extends A> c = ...;
//Now, for example let's say that c is the class of CBA
//How would you get the name of CBA if we didn't know that?```
if that's even possible
Yes I am going to continuously say that until my leg vibrates to alert me of a PR
Yes but how would I get the name of CBA from the class instance?
Thatâs not how it works
.
The class instance of that enum does not hold the enum constants
Like can you get the class of like A.CBA that holds the name CBA
is that how it works
idk if i'm making sense
CBA isnât a class?
^
if you have an enum value you can get its declaring class
It's the enum value
Actually what IS an enumeration value?
i dont think you can extend an enum?
obsidian
has_flint
has_the_recipe
has_obsidian
has_the_recipe
has_obsidian
Cry I prd
Yeah
no you cant
@patent bloom you are probably out of luck then. It will be client side. Possibly available via a datapack
Enums implement interfaces thođ
Pog
yea
Tho itâs a shame enums donât go well with generics
rip ah well
Yo, anybody has any idea why cancelling entitytarget event for zoglins & hoglins does not work?
@lost matrix got a question for you, how would register a tile entity so that the server loads it as that specific entity on server load?
using TileEntityTypes#a doesn't seem to work
Sigh
Imagine getting an instance of an enumeration
This is what I'm fully trying to do. I'm having a method in a class annotated with a specific annotation. Then I'm getting the method, and the thing that is problematic is that I need to get a parameter in the method that is some material (org.bukkit.Material) and then get the actual Material instance.
:0
The method doesnât hold a material instance
Not the material parameters as the very least
When you call the method, that would be the time when you would pass the material instance
@MyAnnotation
public void a(Material.AIR /*I'm trying to get the Material.AIR part */)```
Theyâre instances
does that compile
i mean you cant create a parameter of an enum constant
Tho you could create some sort of annotations mappings if thatâs what you want
could you not just pass the material into the annotation?
I was trying to do smth like this Material m = Enum.valueOf(Material.class, Arrays.stream(method.getParameterTypes()).findFirst().get().getName()); but that obv won't work
Hello, is there something like a console output event?
I wanted it to be in the method
If it's possible
Sysdm sry but thatâs not possible nor how itâs suppose to work
So this is not possible
Wait how does bukkit do it?
With the @EventHandler
fuck
wtf
Poor event
They use it to invoke the method with the passing the even instance
The event instances arenât randomly chosen
oh yeah
I just leave the pings. If people have silly names they deserve the ping đ
bump
lmao
yes it does
Add a LogHandler or what itâs called
how would i do that?
you cant have a method parameter be a Material.AIR constant
thats just not how it works
Thatâs not my point
In principle we could create a similar event handler system but pass material constants instead of event instances
oh yea
thats easy
but i meant like the type of parameter
cant be singular enum constant
@stray halo Logger#addHandler
it doesnt make any sense lol
Rust you say, letâs talk Haskell then
no fuck haskell
and what i have to put in "handler" field?
no fuck you
Create a LogHandler extends ConsoleHandler which overrides publish. then get the default logger .addHandler(yoru handler);
why r u here
you were asking for it
Ah I see youâre an object oriented programmer
You like mutability huh
No thread safety?
Functional programming I don't get either
Side effects
do words like immutability scare you?
LMAO
not rlly
Doubt
rust is literally
immutable by default
also only functional programming ive done is prolog
and that was horrible
sth like this?
public class LogHandler extends ConsoleHandler{
@Override
public void publish() {
}
}
mb
Yeah well then youâve clearly missed something đ
Add a LogRecord as parameter
^
oh i see
Itâs basically a context class
and the record has some method to get the message right?
Is it possible to get the contents of a method? So like ```java
public void printContents(Method method) {
//blah
}```
what do you mean the contents of the method? o.O
You can get itâs accessibility level, params and if itâs static etc
it would be byte code by runtime
Is there like a bytecode to source converter
There is instrumentation
Yes, there is a couple of ways to do it but both are a pain to do
If thatâs what itâs called
Bytecode manipulation also exists
Altho it requires a java agent or smtng
is there any way that is not too hard?
It's doable, but neither efficient nor easy
Not really
You can either read the byte code and somewhat determine what it is or use reflection to get the objects.
Sysdm what are you even doing
lmao
JD Java Decompiler
I can promise some easier solution exists
so then, you really just need the objects?
also why do you need the contents of a method to run in another method? o.O
Something like this java Events.listen(a.event()) .filter(e -> e.getPlayer().getItemInHand() != null && e.getPlayer().getItemInHand().getType() == a.material()) .handler(method.getContents());
fuck
3 back ticks đ
i pressed enter too early
Ok, that doesn't really explain why you need the contents of one method, to then run it through another method
I've tried the logger, but it doesn't log all the console messages, it only logs the message of when i disable the plugin
What logger did you inject the handler in?
also depends on the type of logging as well
plugin.getLogger().addHandler(new LogHandler(this));
You might wanna inject Plugin#getLogger and Server#getLogger iirc theyâre not the same
@stray halo you don't even need to do that o.O
wdym?
@FilteredInteractPlayerEvent(material = Material.SOMETHING, event = PlayerInteractEvent.class)
public void test() {
abc
}``` and then ```java
Set<Method> set = new Reflections("me.zoibox.core.core").getMethodsAnnotatedWith(FilteredPlayerInteractEvent.class);
for(Method method : set) {
for(FilteredPlayerInteractEvent a : method.getDeclaredAnnotationsByType(FilteredPlayerInteractEvent.class)) {
switch (a.event().getName()) {
case "PlayerInteractEvent" : {
Events.listen(a.event())
.filter(e -> e.getPlayer().getItemInHand() != null && e.getPlayer().getItemInHand().getType() == a.material())
.handler(method.getContents());
}
case "PlayerInteractEntityEvent": {
}
case "PlayerInteractAtEntityEvent": {
}
}
}
}```
that is what i'm at so far @wet breach
Using your own Logger generally messes up the logging and you end up running into problems. When you can just grab an instance of the logger for your plugin instead. Not really many valid reasons why you need to inject some other logger.
Maybe heâs only reading the records
so, basically i'm creating a plugin with JDA, and i want to get console ouput and write it in a text channel on a discord server
Yeah
You could just inject the Handler into the plugin logger and the server logger
Idk what other loggers there are
Other plugin loggers maybe
and how do i do that?
Do it at onLoad
btw i changed from plugin.getLogger() to plugin.getServer().getLogger() and it logs more messages, but still not all of them
Then just Bukkit#getPluginManager#getPlugins#forEach or smtng
Yeah ofc
You need both loggers
can you show me a sample code?
No
lmao
You basically already solved this
oh
and what do i have to do in this for loop?
Plugin#getLogger#addHandler(yourHandlerInstance)
If you do that then donât call Plugin#getLogger to inject it in ur plugin logger as that will be done on the loop
ok thx i'll try
If you are wanting to grab all output
then you need to grab the main logger of the server then
Idk if you could inject into the global logger as well doubt it
forget the appropriate name that the main logger is called, think its Minecraft?
//To get the logger of a specific class
private final static Logger LOGGER = Logger.getLogger(MyLogger.class.getName());
private final static Logger LOGGER = Logger.getLogger("Minecraft");
You don't need to inject @ivory sleet just get the reference so you can grab the output from its handler
Well you would need to inject a handler at first?
Wonât magically be passed into a logger?
The logger should have a handler already. Since the logger is created via the server, you only need to grab its reference. Not create a new instance of the logger.
Oh never said create a new logger
DiscordSRV is on github, and last time I checked it was able to print the console to a discord channel. Maybe you will find something interesting in its source code. https://github.com/DiscordSRV/DiscordSRV/blob/master/src/main/java/github/scarsz/discordsrv/DiscordSRV.java
Never worked much with loggers, so idk what is of interest in this repo
Yup, just checked, DiscordSRV still have a remote console feature.
javadocs to find out
declaration: package: org.bukkit.entity, interface: Cat
it says i should be able to
but it doesnt work :/
well you are probably doing it wrong
javadocs say its possible, you are doing something wrong (like doing it if its not tamed)
set tamed doesnt work :/
define doesnt work
guys, i ve been searching but i cant fix it, this is my code and i cant see why its not working ```java
@EventHandler
public boolean onPlayerUse(PlayerInteractEvent interact){
if(container.has(keyMenuWarp , PersistentDataType.DOUBLE)) {
if (interact.getAction() == Action.LEFT_CLICK_AIR || interact.getAction() == Action.LEFT_CLICK_BLOCK) {
interact.setCancelled(true);
interact.getPlayer().openInventory(menuJogos);
}
}
return true;
}
some1 can help me by making this work?
what is container?
public static Inventory menuJogos = Bukkit.createInventory(null, 9,"Modos de jogo!");
public static PersistentDataContainer container;
public static NamespacedKey keyMenuWarp;
đŽ
Aff I gotta go. i'll let you guys explain x)
then onPlayerJoin i have this code keyMenuWarp = new NamespacedKey(this , "MenuWarps"); ItemMeta itemMeta = item.getItemMeta(); container = itemMeta.getPersistentDataContainer();
you do know the container doesnt update when the item is updating
wdym?
well what do u wanna achieve with the code provided
okay
well the way you check the item is somewhat lacking
Wanna open an inventory if someone holds a special item with a special tag right?
yes
with the way your code is, probably best you don't set the inventory object as static
@wet breach
you would actually have to grab the item from the players hand from PlayerInteractEvent#getItem I think or smtng estrit
or if you need to call PlayerEvent#getPlayer#getItemInMainHand
then check if that item has the tag by gettings its meta and then its container and so on
b4 i do that i was checking if the name of the item clicked is equal to the custom item
thats another way
but some people from here said that ill cause troubles
@weary geyser I don't really mess with annotations, but still doesn't really make sense why you need to have this if you have full control of the code? Couldn't you just keep track of the information and send it to the appropriate method the normal way? o.O
?paste
@quaint mantle please remove that and use the past service that is linked
arguably it can
Yes i would register a custom TileEntity if possible. But thats pretty complex.
Using its PDC and replacing the current with a custom one is also viable if you dont want
to tinker with the IRegistry
however assume its in a lobby, then I would say no worries (if you cant get nor manipulate items)
I guess it's explicit enough isn't it ? (about the previous deleted paste)
looks fine
why am i getting this error when i try to suse inventory framemwork??
java.lang.NoClassDefFoundError: com/github/stefvanschie/inventoryframework/pane/Pane
but I would make it to "Attempted to send plugin message through unregistered channel ..." @opal sluice
probably need to shade it
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>SnifferDogs.inventoryframework</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
I tried that but it doesn't work. I'm not sure if I'm messing it up though.
Oh lol, it's not for me ^^ it's the default message of the api I guess it's for the guy who just pasted his code
do u have any ideas ?
?paste entire pom
oh yeah
so how can i do it?
set the scope to compile
like <scope>compile</scope> @sacred sedge
I think that would work
wat server is the plugin suppose to work in as I said if its one of those lobbies then you probably dont need to worry
@sacred sedge make sure all dependencies have a scope set
the dependency block for inventoryframework
any dependencies with a scope of compile get included into the shading automatically if you have the shade plugin set to be used
I finally found a solution!
See last post in this link https://www.spigotmc.org/threads/how-to-get-all-console-output.299146/
huh
ahh
this plugin ill be for all server, this ill be the plugin that manipulates everything
I didnt mean it like that
if you just check the name, the chances are another item with other properties (but same name) can be seen as that item and would also have the ability to open the designated inventory
wait its the same error even with that :(
java.lang.NoClassDefFoundError: com/github/stefvanschie/inventoryframework/pane/Pane
no, this item ill be specific for the lobby
ok
https://www.spigotmc.org/resources/if-inventory-framework.57216/ how it says to add to the project :/
well if you're relocating it
quick question:
how to get the stuff that is logged into the console? couldn't find an event or smt like that
ofc that NCDFE will be thrown if you try to access a class with its original package
inject a ConsoleHandler into the logger you "listen to" with Logger#addHandler
so, can i do it by checking if an item has a specific name?
okok
Any ideas?
did u set the scope to compile?
and what do u run to build the jar?
it should be maven clean install I think
(I dont use maven so rly dk)
then you need to use the maven life cycle tasks as well to build your jar
i just press build artifacts?
hello again, is there a way i can make my plugin disable before all the others?