#help-development
1 messages ยท Page 1509 of 1
yea clone
otherwise when interacting with the inventory, the itemstacks returned are not copies
have to take into consideration most of the documentation is pretty old ๐
most of the time, the comments for methods don't get updated until someone spots a discrepancy lol
Last I checked it still says ExactChoice only works for shaped recipes
But I remember someone showing me it working for a furnace recipe
Bam!, no more broken citizen needed. Made a way better npc system ๐
nice
Made the NPC's client level, so it does not effect the server and also when they follow they follow you and only you on your client
With a new little GUI editing there info
ah so you went the route of packets
well good luck on your updating of it ๐
its already working in 1.17
sure, but its going to break on every major version and maybe some minor versions
yea, but that happen more and more on everything even little stuff lol
that is why I just stick with the API ๐
to much of a hassle dealing with NMS and reflection most of the time
No fun that way lol
How do i add a library?
Why is there no MCE for java :(
gonna need one of those to check out books
But may need to pay for the card tho
Idk what that is, i want to add this:
https://www.spigotmc.org/resources/1-7-1-15-itemparticles-add-particles-effects-when-you-hold-items.70178/update?update=296431
i'm messing about lol
doesn't look like it's intended to be used that way, but i'm assuming you're not using maven/gradle correct?
Jitpack way to go
Hi i need to convert an InputStream into a ConfigurationFile someone konw how to do ? (i need to import a .yml from RESSOURCE folder and not data folder)
YamlConfiguration.loadConfiguration
it's no different than just reading a normal file, there is a method to load it
hahahaha
the get ressource just give an input stream of the file
public InputStream getResource(@NotNull String filename)```
any other method
so how do you convert this inputstream ?
would recommend you look into input/output https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/file/YamlConfiguration.html#loadConfiguration(java.io.Reader)
I use maven gradle i think o.o
you use one or the other
Maven or gradle
MavenGradleโข๏ธ
graven sounds very cool
20 points to gravendor
i don' t understand how can i get the reader
well i just google it...
Jinx
you can read the input steam with an input stream reader, or a buffered stream, both of which that method accepts
again i'd recommend you read into java io
Buffered reader fastest reader
ok so i have a weird problem, this script makes all items generated items unenchanted, but for some reason after chest break it doesn say that the chest was broken as it should
any ideas why?
otherwise it works well
sry i use maven ๐
event.setCancelled(true) probably, as that would prohibit it from breaking
don't compare the material enum with .equals
what should i rather use
==
double equals ==
or what do you mean with say that the chest was broken as it should?
no its breaking properly just the messgae isnt showing up
=.=
you have to install the jar into your local repository to link with it with maven
Does BlockDropItemEvent even fire on a chest break? I think that is player only
Yea but where does it get player from? It would fail there cause the item is dropped from the chest not a player
that would be BlockBreakEvent not ItemDrop
BlockDropItemEvent
hmm why is it blockitemdrop tho
declaration: package: org.bukkit.event.block, class: BlockDropItemEvent
How does that work?
BlockDropItem event will fire for the chest item itself
Youโll want to use getBlockState though
How can I make a "/hub" command that teleport the player to a custom multiverse dimension?
your local repo is like a normal repository which you specify yourself, but on your computer
oh yeah
Okay, tyyy!!
ANd are there any librarys which you would recommend?
Libraries are based on necessity
spigot-api? lol i don't know what you want to do
a quick java question:
class X {
void print(String m) {
Bukkit.getLogger().info(this.getClass().getSimpleName() + " " + m);
}
}
class Y extends X {}
Does whenever calling y.print("gisdng") , does it print X: gisdng or Y: gisdng?
X since it's not implemented in Y
Yaaa i would need a library for Particles >:x
so I would really have to override it for each inheriting class? oof
Hello its me again the random kid who has no idea what they're doing, anyway I'm getting this error when running my plugin af anyone can help it would be greatly appreciated!
Fatal error trying to convert TerrorGames v0.9:me/TerrorGames/SurvivalGames/Main.class
java.lang.IllegalArgumentException: null
Caused by: java.lang.ClassFormatError: Incompatible magic value 3280651198 in class file me/TerrorGames/SurvivalGames/Main
that fixed that proble ty
How can I make a "/hub" command that teleports the player who called it to a custom multiverse dimension?
you have a number that is bigger then what an int can hold, either fix it so the number is lower, or instead of using ints use longs instead
Making a plugin is not hard. How are you generating so many random and never seen before errors?
Are you downloading any files from the internet and possibly trying to interpret them as class files?
nice, you have 3 devs responding to you now ๐
nope I followed some tutorials but thats really it
multiverse dimension are just other worlds and MVD is just a plugin that lets you teleport between them.
You can send the player to the wanted worked with the teleport method.
Make sure you vaildate the world is loaded first
True, this number would exceed a normal int32 value
start with java tutorials
okay thanks I'll try that
generally when java complains about magic values, they are ints
are you trying to read a plugin version or something from a string?
Wth is this error?
Cries in checkstyle complains
quite the version number to exceed the int size ๐
wdym?
You shoudl have seen his error yesterday on Java version
ah so there is some backstory I am missing then
also just a guick do you guys know how to quickly disable this and make it start instantly
Update ๐
You can;t with Spigot
how can i op one specific player in an spigot plugin
PaperMC
there is an argument you could pass it or you can just simply update
Brrrr
-DIReallyKnowWhatIAmDoingISwear add that before the jar command in your batch file
oh lol tysm
yeah you can
I looked and didn;t see that argument supported in Spigot
๐
@digital rain add -DIReallyKnowWhatIAmDoingISwear between your java -jar spigot-1.16.5.jar
between
have to look in the source code lol
yeah, I did
Does anyone know of some good YML file tutorials? My plugin requires me to have a really good understanding of them
If i have an itemstack name that has a colour to it how do i easily read it
cause it has the colour code on it
how can i op one specific player in an spigot plugin

Color code is just a special character
yeye - so how to remove
Seems it works. I learn something new
i guess
it is nice cause i dont have time to update every day
Dun quote me
oh yeah - i guess that could work
but not that reliable
but if it is just a string there isn't much you can do i guess
is it inclusive?
Start inclusive, end no iirc
cool
i bet that just does what solar was saying
it removes all color codes
omg i take a phone call for work and there are like 20 new messages lol
20 is not that many
you have not seen "peak hours"
not yet lol
#help-development-2 when?
i wouldn't mind a per-player one like they have in the python discord
but it is more finnicky
yeah a lot of big programming discords have them, I personally don't like them too much
If that where to happen the ones helping have to be vetted
it's really weird sometimes, it relies on a bot that might fail or not be online, and there'd be like 4-8 channels for helpers to look through all
Cause you can get that one person who knows nothing lol
Not really
so 2 main ones would be better
yeah fair
python discord has like 30 help channels
yeah but python is one of the biggest languages that exist
yeah but the bot runs so well its so nice tho
TypeScript has 13 channels open rn
The Java discord just has 6 channels open for anyone
that makes sense ^^
And stuff like Flutter or the Fabric discord have topic specific ones
so like #help-nms for example
So I'm changing my old class to use reflection but can't get my setBlock method to work... The commented portion is the base I'm trying to turn into reflection...
public void setBlock(Location loc, Material type, int data, boolean physics) {
try {
Class<?> craftworldClass = getCraftWorld(loc).getClass();
Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
setTypeAndData.invoke(craftworldClass, getBlockPosition(loc), generateBlockData(type), physics ? 3 : 2);
//nmsWorld = org.bukkit.craftbukkit.v1_8_R3.CraftWorld.getHandle();
//net.minecraft.server.v1_8_R3.World.setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
````getBlockPosition()` and `generateBlockData()` both have the correct output. Not understanding why its giving an error...
`java.lang.IllegalArgumentException: object is not an instance of declaring class`
ewww - i dislike nms
but would be nice to weed out
for example
Why are you going reflection?
cuz his craftWorldClass is of unknown class?
the declaring class must be the exact class the method intended it to be, not just its subclass
it is the same, you have to import every library
Or.... hear me out... I'm gonna use reflection LOL
yes but you do not need if statment for every check else if or switch that.
so which class is the issue?
so its not
If ...
if ....
This code is over 4 years old... Its just been copied and pasted through out the years to add support for new versions.
idk these classes haha, but you may want to uncomment your previous code to check if the classes you put in getMethod() are indeed the actual method signature
Reflection also might run into a issue where the object declare is not always the same with obfuscation and patch changes. So one method to it all may not work.
but even if so, it should be no such method exception o>o
its almost better to stay on the NMS layer
Then I recode it accordingly.
it just simplifies you code, really, even if you have to cater to different obfuscations
but you cant do that when its different version with different names cause then you are going to have multi methods that do the same thing the NMS layer did and making it more work then what is needed.
still, better than the really large chunk
You could make a interface that allows it to control it a little better with the version and you just update that version class file that is hook with the interface.
I just dun think sticking onto NMS imports solves the problems of using reflection
if there are patch changes, same thing applies to actual imports
never said it solved i said it would be cleaner then using reflection.
you gotta change it
reflection gets dirty fast!
Ok so I modified it a little
public void setBlock(Location loc, Material type, int data, boolean physics) {
try {
Class<?> craftworldClass = getCraftWorld(loc).getClass();
Object blockData = generateBlockData(type);
Object blockPos = getBlockPosition(loc);
Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", blockPos.getClass(), NMSBlockData, int.class);
setTypeAndData.invoke(craftworldClass, blockPos, blockData, physics ? 3 : 2);
//nmsWorld = org.bukkit.craftbukkit.v1_8_R3.CraftWorld.getHandle();
//net.minecraft.server.v1_8_R3.World.setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
It looks like Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", blockPos.getClass(), NMSBlockData, int.class); is correct but the invoke isn't...
and tbh with newer version of Java reflection is getting harder
Is it?
all spigot has to do it make that a final field and your reflection will never work
NMSBlockData is a Class object right
yes
you can not access the modify object anymore in java 16+
thus can not edit the final field and does not work anymore
Hmm aight I gotta try that
ok so I assume setTypeAndData is static method
if so
Afaik only true constants cannot be changed
then you should invoke on null
[16:49:58 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
Disconnected from the target VM, address: '127.0.0.1:55471', transport: 'socket'
dahell? i accepted eula dafuq it means lol
it is yes. so setTypeAndData.invoke(null, blockPos, blockData, physics ? 3 : 2); ?
yep
k one sec
Hmm but you can still use unsafe tho?
[14:51:33] [Server thread/WARN]: java.lang.NoSuchFieldException: modifiers
[14:51:33] [Server thread/WARN]: at java.base/java.lang.Class.getDeclaredField(Class.java:2549)
[14:51:33] [Server thread/WARN]: at net.beyondblocks.core.utilities.ReflectionUtilities.setPrivateFinal(ReflectionUtilities.java:63)
Cant be unsafe if it cant field the field at all.
No I mean Unsafe
java.lang.NoClassDefFoundError: com/mojang/brigadier/arguments/FloatArgumentType
at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry$4.read(Commands.java:363)
at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry$4.read(Commands.java:355)
at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry.read(Commands.java:561)
at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry.access$000(Commands.java:307)
at net.md_5.bungee.protocol.packet.Commands.read(Commands.java:84)
at net.md_5.bungee.protocol.DefinedPacket.read(DefinedPacket.java:242)
at net.md_5.bungee.protocol.MinecraftDecoder.decode(MinecraftDecoder.java:40)
at net.md_5.bungee.protocol.MinecraftDecoder.decode(MinecraftDecoder.java:10)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)
07:50:24 [INFO] [klugemonkey] disconnected with: NoClassDefFoundError : com/mojang/brigadier/arguments/FloatArgumentType @ net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry$4:363```
sun misc Unsafe
hmm have not tired that
causes an NPE
erm, the npe should not be caused by the first argument
Ill test one sec
does java SE 1.8 still works on spigot/paper 1.17?
Never used sun misc Unsafe before
on the topic of testing, how do you guys write unit test cases for plugins
I don't for Minecraft code. For work I use RanorexStudio
Make a test case and send to the QA team to clean up and put in there end to end testing
i feel like this is something simple enough for you to figure out on your own
yeah thats true sorry xD
pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData);
setTypeAndData.invoke(null, blockPos, blockData, physics ? 3 : 2);
``` `DEBUG >> blockPos: BlockPosition{x=-23, y=103, z=320} BlockData: Block{minecraft:air}`
Still an NPE
is setTypeAndData static?
should take a look at unsafe if you think using reflection gets dirty fast ๐
where is the method coming from
((net.minecraft.server.v1_8_R3.World) nmsWorld).setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition(l.getBlockX(), l.getBlockY(), l.getBlockZ()), net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
see this
Well I've tried both using a declaring class and not so ๐คท
No.
https://paste.md-5.net/ayebenewic.java
channel.pipeline().addFirst(KEY_SERVER, new ChannelHandler(channel)); //Works
channel.pipeline().addBefore(KEY_SERVER, KEY_PLAYER, new ChannelHandler(channel)); //Exception
I am only receiving netty packets, no nms packets
name: BarrySk
version: ${project.version}
main: com.barrysk.barrysk.barrysk.BarrySk
api-version: 1.16
authors: [ barry ]
description: First Skript addon by barry
it says invalid plugin.yml, why so
Yea going to make a note to look into unsafe
you're invoking it on the Class object, not an actual instance of it
make sure the ${project.version} is getting replaced when you build
ok my bad, idk why the craftworldClass in the invoke method lol
Ok let me test
ohh think i found the issue
Yeah although should be said it's subject for removal (in the future so probably nothin you have to worry about)
good luck on that, hardly any documentation for it considering that the only time you really need it is rare instances you need to directly invoke something on the JVM itself lol
nah nvm
still curious if they could fully remove unsafe or not
oh wtf it says it doesnt contain the plugin.yml
Somebody knows?
setTypeAndData.invoke(getCraftWorld(loc), blockPos, blockData, physics ? 3 : 2); like that then?
I'm assuming getCraftWorld(loc) returns the actual nms world object?
if so then it should work
java.lang.IllegalArgumentException: argument type mismatch
create a directory inside of main called resources and still your plugin.yml there
what is getCraftWorld
and any other resource you want at the root of the jar
it is in main
you could search it up on the documentation
public Object getCraftWorld(Location loc) {
try {
return getHandle.invoke(NMSCraftWorld.cast(loc.getWorld()), new Object[]{});
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}
then should look at your pom then because resources should automatically get placed in the jar otherwise
gradle gang
well im using that minecraft plugin on intellij
that is fine, what does the pom look like?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
my bad
wich version do i need then? java 16?
yes
ok ty
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
@fiery inlet remove this from the pom and it should fix your problem
but that pom is pretty short i must say
is there a way to post a release without it being the latest for download, say like a beta?
Will this work with String.format()?```java
ResultSet result = statement.executeQuery(String.format("SELECT * FROM simpleEco WHERE uuid=%s", uuid.toString()));
nope, just have to append the tag beta on it so people know and if you are using the spigot web API, a way to filter it out if you have an update checker thing @echo saddle
I need something like a hashmap with a third dimention? What are those called?
Like
String, String: Value
you need a 3 dimensional array?
HashMap<HashMap<>, sth>
now it loads hurrah
oh, hashmap in a hashmap
but it still aint log sheit
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "Debug,sk.");
this.getCommand("test").setExecutor(this);
}
or show up in /pl dafuq
at least you made some progress ๐
i made all this in 1.8 which supposedly is harder
now i cant do this
why is it always so hard to start a project lol
have a boilerplate
anyone know why it doesnt load?
any console messages?
chances are it didn't even detect a plugin.yml
well then it would say that wouldnt it
well, i can put any kind of jar in plugin folder
does my pom have to be in resources
no messages will show up
no
ok gucci
plugin.yml is only thing in resources
name: BarrySk
version: ${project.version}
main: com.barrysk.barrysk.BarrySk
api-version: 1.16
authors: [ barry ]
description: First Skript addon by barry
simple
does your main class extend JavaPlugin
yup
^
actually not quite true, if you put a jar that doesn't implement BasePlugin or JavaPlugin the server complains about it with a single line ๐
can you send your full main class in a paste aswell
Ok so current code:
public void setBlock(Location loc, Material type, int data, boolean physics) {
try {
Class<?> craftworldClass = getCraftWorld(loc).getClass();
Object blockData = generateBlockData(type);
Object blockPos = getBlockPosition(loc);
Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData);
setTypeAndData.invoke(getCraftWorld(loc), blockPos, blockData, physics ? 3 : 2);
//nmsWorld = org.bukkit.craftbukkit.v1_8_R3.CraftWorld.getHandle();
//net.minecraft.server.v1_8_R3.World.setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
And current error:```
DEBUG >> blockPos: BlockPosition{x=-23, y=103, z=320} BlockData: Block{minecraft:air}
java.lang.IllegalArgumentException: argument type mismatch
uhh, i use the last version of eclipse but there is no java 16, the last one is java 15
try putting the physics predicate outside
did you actually copy the new jar to the plugins directory and did you make sure to restart the server afterwards and not just use reload?
mhh
LOL
I found it... craftworldClass is giving net.minecraft.server.v1_8_R3.WorldServer instead of net.minecraft.server.v1_8_R3.World
been looking around, but blockData could be wrong since its toString Block{minecraft:air}, which could refer to the bukkit block but I'm not too sure with these nms classes
i believe WorldServer is a subclass of World
can always do hot swapping instead ๐
true
yeah gonna get its parent class. and test that
yeah well i dont know why it doesnt contain plugin.yml
try building fresh
that is, remove the build directory, not your project and then build it
what delete src
the directory where the jar appears
when you build
it is a separate directory then that of your src directory o.O
out folder
Method setTypeAndData = craftworldClass.getSuperclass().getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData+" craftworldClass: "+craftworldClass.getName());
setTypeAndData.invoke(getCraftWorld(loc), blockPos, blockData, physics ? 3 : 2);
``` this didn't work either...
How could I run a command the moment a player connects?
@stone sinew int.class wouldn't you want this to be Integer instead?
that causes invalid variable in the method.
list for the join event, run said command
nothing to it really
java.lang.NoSuchMethodException: net.minecraft.server.v1_8_R3.World.setTypeAndData(net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.IBlockData, java.lang.Integer)
i think blockData might be wrong then
it works on all other methods that use blockdata... like my getmaterial method
whatever you're passing in might not be an instance of whatever NMSBlockData represents, or the other one
public Object getBlockData(Location loc) {
try {
Object craftWorld = getCraftWorld(loc);
Object blockPos = getBlockPosition(loc);
Method method = craftWorld.getClass().getMethod("getType", NMSBlockPosition);
return NMSBlockData.cast(method.invoke(craftWorld, blockPos));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Hmm from what I understand they want to substitute it rather
if they can come up with decent substitutes then I am for it ๐
Where do I buy a factions plugin?
Well it depends how much do you want to get scammed
what does NMSBlockData.cast( do?
What?
casts it to blockdata
because it looks like the getType method already returns IBlockData, which is what you want
spigotmc is a good start xd
blockData = ((org.bukkit.craftbukkit.v1_8_R3.CraftWorld) loc.getWorld()).getHandle()
.getType(new net.minecraft.server.v1_8_R3.BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
material = org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers.getMaterial(((net.minecraft.server.v1_8_R3.IBlockData) blockData).getBlock());
``` this is literally just copied to match in reflection.
'setString(int, java.lang.String)' in 'java.sql.PreparedStatement' cannot be applied to '(java.lang.String)' java statement.setString(uuid.toString());How do i fix this
I need a factionsss plugin
Yeah we know. I've told you what to do and this is the wrong channel
how does ur statement look
reparedStatement statement = connection.prepareStatement("SELECT * FROM simpleEco WHERE uuid=?");
statement.setString(uuid.toString());```
all i can say is to just try it without NMSBlockData.cast( and return the object invoke returns, otherwise i'm stumped
setString(1,uud.toString) iirc
I can try it.. but doesn't have issues on all the other methods that use the same object
thx alot
that method makes me think it does the opposite XD
Same error even without casting
did clearing out the build directory help?
did you rename generateBlockData to getBlockData?
No... one generates the data using a material input one gets the block data from a location
i'm assuming generateBlockData works as intended then? since that's the one you actually use for this and not getBlockData
when i do uuid.toString() does it return it with the dashes or without the dashes
yes.
thx
i have no idea then
ugh i hate this new tab menu since 1.9 ....
DEBUG >> blockPos: BlockPosition{x=-23, y=103, z=320} BlockData: **Block{minecraft:air}** craftworldClass: net.minecraft.server.v1_8_R3.World
Interesting.... java.lang.ClassCastException: Cannot cast net.minecraft.server.v1_8_R3.BlockAir to net.minecraft.server.v1_8_R3.IBlockData
Object craftWorld = getCraftWorld(loc);
Class<?> craftworldClass = craftWorld.getClass();
Object blockData = generateBlockData(type);
Object blockPos = getBlockPosition(loc);
Method setTypeAndData = craftworldClass.getSuperclass().getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData+" craftworldClass: "+craftworldClass.getSuperclass().getName());
setTypeAndData.invoke(craftWorld, blockPos, NMSBlockData.cast(blockData), physics ? 3 : 2);
sounds like blockData is wrong then
well makes sense I suppose
BlockAir doesn't contain any data at least not that I recall anyways lol
Why would the same blockdata work in the getType method when i getMaterial???
But isn't it blockstate that gets casted to blockdata and not the block type?
bump still not fixed, waiting
IDK honestly.
How can I generate blockdata just based on material then?
because defaults exist
generating block data isn't the same as casting
I'm missing a method... CraftMagicNumbers.getBlock returns an NMS Block... How do I convert that to block data?
you would grab the blockstate if I am not mistaken
wait... I just checked it has getBlockData()
or there you go
org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers.getBlock(Material.AIR).getBlockData()
FML
man i just made a whole new project, did nothing, and added a logging function and it worked
i did something and idk what earlier lol
the reason I was telling you to clear the build directory is because your problem was a caching problem
there is a menu option for intelliJ to clear caches
usually start with the easiest and that is the build directory
and then if that don't work move onto the IDE options
since both IntelliJ and Maven use caching
whats the best way of making/registering commands
i'd rather start making them right instead of having to change method later
https://github.com/hawkfalcon/ServerTutorial/tree/master/src/main/java/pw/hwk/tutorial/commands
@fiery inlet
that is how I make most of my commands
they are usually just sub-commands of the main one
unless I have a command that doesn't fit being a subcommand
this way, I only need to register 1 command usually and can just easily add however many sub-commands I want ๐
FINALLY!!!!!!
hopefully I was of some help @stone sinew and as well as others lol
do i need res.next() or can i just do res.getfloat ```java
PreparedStatement statement = connection.prepareStatement("SELECT * FROM simpleEco WHERE uuid=?");
statement.setString(1, uuid.toString());
ResultSet result = statement.executeQuery();
while (result.next()){
double amount = result.getFloat("balance");```
the problem with your method is that it will skip the first result
Im sorry I dont follow
the moment next() is invoked, it will skip the first result if there is more then 1 result
by subcommands, you mean /maincommand [subs]
like arguments?
ok
Yeah thanks to you, @unreal quartz and @hardy swan lol
public Object generateBlockData(Material type) {
Object data = null;
try {
Method getBlock = NMSCraftMagicNumbers.getMethod("getBlock", Material.class);
Object nmsBlock = getBlock.invoke(NMSCraftMagicNumbers, type);
Method getBlockData = nmsBlock.getClass().getMethod("getBlockData");
data = getBlockData.invoke(nmsBlock);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
return data;
}
public void setBlock(Location loc, Material type, int data, boolean physics) {
try {
Object craftWorld = getCraftWorld(loc);
Class<?> craftworldClass = craftWorld.getClass();
Method setTypeAndData = craftworldClass.getSuperclass().getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
setTypeAndData.invoke(craftWorld, getBlockPosition(loc), generateBlockData(type), physics ? 3 : 2);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
yes, the link I gave you shows you how I did it for that plugin
It starts at 0 where there is no result
I mean that is an obvious if there is no results
So if im just trying to get a value in it no matter what can i just do result.getFloat
If i even helped lol
Now I just gotta work out why the hell the same method I use on my test plugin takes 64ms and lags the server out but on my test plugin only takes .54ms
row 0 is not always empty
It is
youโll want to cache your resolved methods
Calling next() on 0 will lead you to the first entry
A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row;
so if im trying to get index 1 i need next
Actually idk what yall talking about lol, i just guess it is reader stuff
What you said is what I mean
Its not that. It was doing that before reflection.
I must have been remembering something else with next()
so frost
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (label.equalsIgnoreCase("Hello")) {
if (sender instanceof Player){
Player player = (Player) sender;
player.sendTitle(ChatColor.translateAlternateColorCodes('&', "&7[ &e&lCOINS &7]"
), ChatColor.translateAlternateColorCodes('&', "&fHello"), 20, 100, 60);
} else {
sender.sendMessage(ChatColor.RED + "Only executable by a player!");
}
}
return true;
}
this is a bad way of doing it or?
generally don't need all them Annotations, but you are using label instead of cmd. The Label is not always the same name as the command being ran.
I sometimes wonder why people dun just use ยง directly
I wouldent use nested if statements and you really shouldent check the label
Because it wont show up on certain systems
because java doesn't like it sometimes ๐
so how would i do it with cmd
and because of that wont color the message
if (cmd.equals("Hello")) {
?
it will actually color the message
You shoulden't be needing to check them
huh
that's what translateAlternateColorCodes is doing
oh yeah i know
@fiery inlet the link I gave you earlier contains quite a few command classes
well that stuff just got confusing cuz it gave all kinds of errors
it has a main command class, and then sub command classes
Just create a static Chat.colour(String) in a utility class and make it use chatcolor.translate...
you are forgetting about encodings and second also forgetting about methods that are not expecting that character for colors before being processed internally
so sometimes it works, and other times it will just print that character out instead
that is why there is methods to apply color or remove color
this.getCommand("Hello").getExecutor(this);
is it not this that gets the command in
aswell as plugin.yml ?
if you are expecting string inputs from players at runtime then sure, it make sense to translate, but if you want to only use them when writing plugins, prob dun need it
I am telling you why developers don't use that character instead of using the methods
but the encoding part makes sense
Java has issues sometimes when you use unicode characters in a string and expect it to be processed normally
then do the same issues apply to other languages with special characters?
sometimes, but Java has the ability to interpret unicode characters directly though
Now it says unknown command, and doesnt log the thing anymore after making a command, wtf
main class
https://pastebin.com/Fp2en4WG
plugin.yml
https://pastebin.com/vpqfsAcW
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ah okk
I've heard there's treatments for that.
WDYM? Like if lerpx is -5 you want x to be 10?
-10
Send the log again I think that would be useful
what's the output x in each case?
What are you trying to do? because AFAIK that code will always give you the exact same output no matter how many times you execute "run()"
Welp.... reflection is slower then I thought.
like: x + x + lerpx 'll getting the value of the x and sum with lerpx
I'm still not sure what's going wrong here.
Or what you're trying to use this for. Could you explain more about what this is being used for? Or if someone else knows then feel free to jump in.
looks like maybe for random teleporting
i want to a make gun camera recoil
@minor garnet first, stop using Math.random() everywhere and make an instance of it instead so you can re-use the object. Second, the way you have setup your algorithm you are not going to have much randomness
With the vault api what is the difference between createBank and createPlayerAccount
createBank lets you make a bank without a player being attached, the second is creating an account in a bank for a player
its hard to expalin it.. but
Hey guys, this is my fluffly recoil system, i'm not using shake cam and spray. It's dynamic with blueprints: curves, timelines, vectors, lerps, rotators, delta, time by handle, custom events, arrays, etc etc
So... i hope you like it
however, multiplying two negatives results in a positive because that is how math is done @minor garnet if you were wanting to keep the sign, then check for the sign then apply it afterwards
https://cdn.discordapp.com/attachments/780140066659500043/854398892220612648/Screen_Shot_2021-06-15_at_12.36.06_PM.png if i have a db like this I dont need createBank just PlayerAccount right
that's why I put it as
positive the value
I am not sure what you are trying to do. Are you making your own economy plugin?
Yes
then why are you worried about vault?
How many times does this entire code run?
in this case I would check if both values โโwere greater than or equal to maxy, or maxx
Its required. The client wants vault hook in
OK say you added a print statement after
final int miny = 1, maxy = 5,
minx = 1, maxx = 5;
How many times would that print statement run?
until lerp reaches the value of random
after that I would make the crosshairs go down
so reverse mode that I would subtract the value of y and x until I get to 0
ok, but vault isn't going to work for your custom economy plugin unless vault implements your economy plugin too
It does
in that case, @plucky comet it does whatever you want it to
@minor garnet Could you show more of the code? I'm struggling to understand how it's supposed to work.
I'm not sure why you have a BukkitRunnable in there.
in this case it goes up and down only
Maybe I'm blind but where can I find the API changes for bungeecord (1.17)?
Thanks ๐
hahah i got NPC's to sit ๐
@sand void So just to make sure I understand, what's supposed to happen is that you call cameraRecoil, the player's camera moves up a random amount over some number of ticks, then moves down to the start over the same number of ticks?
wrong ping bud
Sorry!
no worries
@minor garnet So just to make sure I understand, what's supposed to happen is that you call cameraRecoil, the player's camera moves up a random amount over some number of ticks, then moves down to the start over the same number of ticks?
But from looking at the code it looks like at the moment it only moves up and doesn't move back down?
its hard to explain because english is not my main language but
So what's the issue then? Is it not doing what you want already?
when the number there on the ly is positive it goes down
I just want to solve the sum problem
I generate a negative or positive float if I add two negative numbers, it will be positive
actually i think i already know what i should do
Oh I also missed the "old code" below the code snippet you sent most recently... Looks like I'm just a bit blind
How can I use a custom player head ?
Check spigot javadocs + google.com
Does anyone know how to force the name of entity to not show and stay hidden?
<>.setCustomNameVisible(false); does not work
NMS?
hmmmm
it isn't
Or drop support w/e they want, or update with to many issues.
Anyone here know the scary ambient sounds underwaters name?
declaration: package: org.bukkit, enum: Sound
its the same if i do Sound.
theres just 1 billion sounds xd
and idk which one is the right one
and there is nowhere that i can just listen to them
without testing all xd
well, I mean you don't have that many for underwater ambient ones
i went with lightning xd easy
one thing though
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
ItemStack sword = new ItemStack(Material.NETHERITE_SWORD);
ItemMeta meta = sword.getItemMeta();
meta.setDisplayName("ยง7[ ยงeยงlGOD-SWORD ยง7]");
meta.addEnchant(Enchantment.DAMAGE_ALL,50, false);
meta.addEnchant(Enchantment.FIRE_ASPECT, 25, false);
meta.addEnchant(Enchantment.FIRE_ASPECT, 10, false);
sword.setItemMeta(meta);
p.getInventory().addItem(sword);
p.sendMessage("ยง7[ยงcยงlGOD-SWORDยง7]");
p.playSound(p.getLocation(), Sound.ENTITY_LIGHTNING_BOLT_THUNDER,1, 1);
}
return true;
}
no enchants are added dafuq
When was the chat API change made (net.md_5.bungee.api.chat.hover.content etc.)?
Because HoverEvent deprecated constructor .. :|
how to strike lightning at location
Anybody knows where i could learn stuff like rotation matrix etc?
More math in general
nvm found out
This is why I usually tend to update the library and then PR it to them
Khan academy is pretty good for maths in general I think.
I have a weird problem. When I send a BaseComponent the player sometimes receives the message but sometimes he do not receive the message. Why?
Where is the flag that determines whether the dragon is going to drop an egg actually stored? Is it part of the dragon itself and thus the map?
Why am I getting teleported to a specific point all the time when I put that in the PlayerMoveEvent:
vector = event.getTo().subtract(event.getFrom()).toVector();
try to clone it beforehand
It appears that .getTo does not return a clone but the actual instance, and since #substrace mutates the object the player is teleported
anyone know a solution to maven complaining about this
using shade 3.3.0 snapshot
[WARNING] - META-INF/LICENSE
[WARNING] - META-INF/NOTICE
[WARNING] ItemBlacklist-0.3.2.jar, bstats-base-2.2.1.jar, bstats-bukkit-2.2.1.jar, commons-lang3-3.4.jar, maven-model-3.3.9.jar, plexus-utils-3.0.22.jar, semver4j-3.1.0.jar define 1 overlapping resource:
[WARNING] - META-INF/MANIFEST.MF
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/```
oh okay thank you
I was well late there
Either ignore it or do a lot of excludes
Does anyone know if I have to use Java 1.16 to compile my plugin if I'm building against remapped Spigot?
I seem to get some weird errors if not (cannot access classes, auxiliary classes, etc) but I would prefer not to lose compatibility with older Java versions.
Are you compiling against spigot-api or spigot?
Both, I have a multi-module project, one module compiles against remapped spigot (per md5's post)
Everything looks ok until I try to build, but then I get errors trying to access any of the remapped NMS classes
And I assume that you assume that I know these errors
(I did see Aniby was having the same error, but not sure they got a resolution and I don't wanna ping them)
It literally just says "Cannot access <class name of NMS class>" with no extra info. Not assuming you know anything ๐
compile or runtime?
Compile
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project CompatibilityLib-v1_17_0: Compilation failure
[ERROR] /Users/nathan/Documents/Code/Bukkit/MagicPlugin/CompatibilityLib/v1_17_0/src/main/java/com/elmakers/mine/bukkit/utility/platform/v1_17_0/CompatibilityUtils.java:[112,25] error: cannot access BlockPos
[ERROR]
Specifically that, but I was hoping someone would just generally know if Java 1.16 is required at compile time.
The post was unclear on this subject.
still
[WARNING] maven-model-3.3.9.jar, plexus-utils-3.0.22.jar define 2 overlapping resources:
[WARNING] - META-INF/LICENSE
[WARNING] - META-INF/NOTICE
[WARNING] ItemBlacklist-0.3.2.jar, bstats-base-2.2.1.jar, bstats-bukkit-2.2.1.jar, commons-lang3-3.4.jar, maven-model-3.3.9.jar, plexus-utils-3.0.22.jar, semver4j-3.1.0.jar define 1 overlapping resource:
[WARNING] - META-INF/MANIFEST.MF
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/```
Most of those you should be setting provided on.
so not shaded
i dont quite get you
where do i set them as provided?
?paste your pom
you add a scope on yoru dependencies that you don;t need included
Yea, no idea what happened. I could guess you could try using the --stacktrace flag, but idk if maven is using it
disable it and return maybe
beware, this could also lead to fatal errors in the disable block
Why? xml <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-model</artifactId> <version>3.3.9</version> </dependency>
or just throw new RuntimeException()
not sure if im honest
throwing exceptions on enable only disables the plugin
is there an easier way to fix method parameters not matching? it seems kinda excessive to have to go through each file and fix tons of these... https://i.imgur.com/gxFk4fD.png
Fix the LVT
thanks that works!
Or change the configuration of the decompiler
Not entirely how the second scheme is called, could be jad-style varnames but idk for sure
hmm, okay. thanks
no my bad, JVN was varx, so def. not it
Hey, does anyone have an idea for an NMS Body Rotation Problem? https://www.spigotmc.org/threads/nms-rideable-ravager-body-rotation.510665/
it compiled nicely but it throws this after i changed the scopes to provided
yes you have to only set to provided if its on your server
how do i know if its on the server or like
have you an idea on how I could damage a player when getting thrown or he runs against a wall? I tried it with the MoveListener and get getTo() but that only works when the player is in the Block he "hits" like in grass...
Could not load 'plugins\Scaffold.jar' in folder 'plugins': uses the space-character (0x20) in its name I got this error and Im not sure where the space is located
you'll have to know which direction your wall points to I guess
(north/south/east/west)
see if it is X or Z coordinate that will increase or decrease
but not a specific wall I just want to damage the player when he runs against a block
Oh you mean if he increases in x I check if there is going to be a block?
x OR z
yeah but then I would damage him really often i think so
you would have to check if it is a wall (> 2 blocks) on the same Y
otherwise yes it will damage in every ascending terrain
okay.. hmm
Can anyone help
check your plugin.yml
in the name?
yes ? maybe
Can I call an event that can only be โheardโ from within the plugin I called it from?
Or - like make the class public to only the jar it is in or something like that
oh i just had to provide the spigot api
That would be a normal Method
What's the chat event?
PlayerAsyncChatEvent
thank you
java.lang.IllegalStateException: InventoryOpenEvent may only be triggered synchronously.
Did you mean AsyncPlayerChatEvent
yeah
If I'm correct you can check through that to see if a command has been ran
now only the manifests overlap, do i just manually exclude them?
Material.LEGACY_BURNING_FURNACE
``` Would this be for a furnace cooking something
?
yes
okay because im trying to make furnaces cook faster
like setting the cook time, im going to assume
you don't want to use legacy materials
its the only burning furnace option
iirc whether a furnace is burning or not is now controlled by the block's state
it's no longer a separate material
so what should i use if i cant use legacy
Furnace furnace = (Furnace) block.getState();
furnace.setCookTime((short) 100);
so that getting the state then setting the cook time
or, as bukkit calls it, the BlockData
hi NNY: )
chin and nose man
You miss me
did you get your problem solved
yea
roblox is gay
yeah i dont play it
does AsyncPlayerChatEvent not check for commands too?
it's exclusively for chat iirc
^^
hm ok
im only playing it cuz i dont want my brother to annoy me
;-;
use command preprocess event if you want to catch would-be-commands
so I have to use PlayerCommandPreprocessEvent
Yes
Roblox is a browser game right or does it have an app now?
its not a browser game
just get 2 cpus
big bren
lol
speaking of browser games
i'm itching to write a bot that uses like a headless browser or something to play some browser games
is travian still a thing?
?paste
What part of my code in the loop is causing this error?
[13:40:09] [Server thread/WARN]: [NathansEnchantments] Task #506 for NathansEnchantments v0.0.1 generated an exception
java.lang.ClassCastException: class java.util.Collections$UnmodifiableRandomAccessList cannot be cast to class org.bukkit.entity.Player (java.util.Collections$UnmodifiableRandomAccessList is in module java.base of loader 'bootstrap'; org.bukkit.entity.Player is in unnamed module of loader 'app')
at me.nathan.enchants.Main$1.run(Main.java:49) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Paper-776]
at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.16.5.jar:git-Paper-776]
at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1427) ~[patched_1.16.5.jar:git-Paper-776]
at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:436) ~[patched_1.16.5.jar:git-Paper-776]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1342) ~[patched_1.16.5.jar:git-Paper-776]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1130) ~[patched_1.16.5.jar:git-Paper-776]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-776]
at java.lang.Thread.run(Thread.java:834) [?:?]
@EventHandler
public void onFurnaceSmelt(FurnaceSmeltEvent e) {
Furnace furnace = (Furnace) e.getBlock().getState();
furnace.setCookTime((short) 100);
}
``` So this would work
at me.nathan.enchants.Main$1.run(Main.java:49) ~[?:?]
I know that something in the loop is causing it
?paste
Feel free to show us what you have to so we can help ๐
ItemStack pickNew = ((Item) e).getItemStack();
Why are you casting a list of players to a single player
This too what
It's the only way I was able to get it back into an item stack
don't cast things if you don't know what you're doing
u cant cast a list of players to a player also
I mean, what else am I supposed to do to make it an item stack?
assuming e is an instanceof Item, that's fine
e is an entity
an entity isnt always an item
Player player = (Player) Bukkit.getOnlinePlayers(); wtf is this
yeah, don't cast if you don't know what you're casting
Bukkit.getOnlinePlayers() returns a Collection<Player>
you can not cast Collection to Player
a Collection will never be a Player
a bucket full of oranges will never be an orange
even if there is only one orange
Then how am I supposed to search the player?
there will still be a bucket
you iterate over the collection
you have multiple players
you need to do something for each player
for (Player player : Bukkit.getOnlinePlayers()) {
I need entity because e would just be the book and not the pickaxe, I need to get the pickaxe as an itemstack to add an enchantment
for (Player player : Bukkit.getOnlinePlayers()){
for (Entity entity : player.getNearbyEntities(3, 3, 3)) {
if (entity instanceof Item && pick == Material.NETHERITE_PICKAXE || pick == Material.DIAMOND_PICKAXE || pick == Material.GOLDEN_PICKAXE || pick == Material.IRON_PICKAXE || pick == Material.STONE_PICKAXE || pick == Material.WOODEN_PICKAXE) {
Item i = (Item) entity;
for (Entity e : i.getNearbyEntities(1, 1, 1)) {
if (e instanceof Item && item.getItemMeta().getDisplayName() == ChatColor.LIGHT_PURPLE + "Telepathy Core") {
e.remove();
ItemStack pickNew = item.getItemStack();
pickNew.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
}
}
}
}
}
are you trying to do a "enchant by dropping items on top of one another" thing
Yes, @wraith rapids
listen to item drop events instead
Is there a way to simplify this line java if (args[0].equalsIgnoreCase("bal") || args[0].equalsIgnoreCase("balance"))
I was told that wasn't reliable
checking every item near every player constantly is dumb
this isn't any more reliable
Okay
if you want it to be super reliable, you would have to be a little bit smarter in order to not kill the server
something along the lines of iterating over all items in the world and populating a context map keyed by blockkey
Or do it on item drop
@plucky comet is "bal" the command name?
no
you could do
create a set of aliases and check contains
if you do ^ make sure you check the length cause if you type 2 characters and its looking for 3 (BOOM!)
im p sure if second index is out of bounds java doesnt care
it does
it does
huh.
its not python
@wraith rapids how would I check for the book, now?
@EventHandler()
public void onItemDrop(PlayerDropItemEvent event) {
ItemStack item = event.getItemDrop().getItemStack();
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!(item.getType() == Material.NETHERITE_PICKAXE || item.getType() == Material.DIAMOND_PICKAXE || item.getType() == Material.GOLDEN_PICKAXE || item.getType() == Material.IRON_PICKAXE || item.getType() == Material.STONE_PICKAXE || item.getType() == Material.WOODEN_PICKAXE) {
return;
} else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
return;
} else {
for (Entity entity : )
}
}
I'm stuck on that
Basically, how do I make the pickaxe an entity that can be used to search nearby?
nvm
Other note, might be esier to do item.getType().toString().endsWIth("PICKAXE"), rather than the individual pickaxe checks you do now
ideally you would use the material tag for pickaxes
as that is significantly faster
That still is the material
what
Just if the material name ends with PICKAXE
yes, that is slow
and it isn't guaranteed that every pickaxe ends in PICKAXE
use the tag
there's like a material tag somewhere for each of the tools and weapons
MaterialTags.PICKAXES.isTagged()
I can't find that anywhere in docs
org.bukkit.Tag?
i think MaterialTags is paper actually
Yep
Not there
There is also Bukkit.getTag iirc, but it is a bit overkill for our purposes
There's only mineable with pickaxe
Bukkit#getTag
There is cluster_max_harvestables which does the same thing from looking at it
So basically useless here?
You're talking about org.Bukkit.Tag, right?
there is no other tag class
the Tag class doesn't seem to have a tag for pickaxes
^
It has cluster_max_harvestables though
The closest I see is NEEDS_DIAMOND_TOOL
Which according to the minecraft wiki has all the pickaxes listed
That looks like 1.17 only
Added in 21w11a
and yeah clusters smell like 1.17
Ye
that's not a list of pickaxes though
Most tags were created with 1.17; hopefully mojang keeps at it with adding tags
I'm working with 1.16.5
that "cluster max harvestables" and "pickaxes" happen to align isn't guaranteed
Just use an EnumSet then and define them manually
or use paper
meh. You're not wrong
This error has confused me way too many times :/
I know
Just every time I see that my brain like turns off
Well shit
Big brain time
package.Class.method(X) cannot be applied to package.Class.method(Y) means you need a signature of X but you're giving it Y
the fully qualified class names make it cancer to read
but basically you just need to compare the parameters
Enchantment, int
vs
Enchantment
and the resolution becomes obvious
@EventHandler
void onFurnaceBoosterSmelt(FurnaceSmeltEvent event) {
Furnace furnace = (Furnace) event.getBlock().getState();
furnace.setCookTimeTotal((short) 1);
furnace.setCookTime((short) 1);
furnace.update();
}
``` I just get a GUI error...
"gui error"
like the furnace just duplicates its smelting gui
Alright, want to make 100% sure this will work. This should work, right?
@EventHandler()
public void onItemDrop(PlayerDropItemEvent event) {
ItemStack item = event.getItemDrop().getItemStack();
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!(item.getType() == Material.NETHERITE_PICKAXE || item.getType() == Material.DIAMOND_PICKAXE || item.getType() == Material.GOLDEN_PICKAXE || item.getType() == Material.IRON_PICKAXE || item.getType() == Material.STONE_PICKAXE || item.getType() == Material.WOODEN_PICKAXE)) {
return;
} else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
return;
} else {
for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
ItemStack item2 = event.getItemDrop().getItemStack();
if (e instanceof Item && item2.getItemMeta().getDisplayName().equals(ChatColor.LIGHT_PURPLE + "Telekinesis Core")) {
e.remove();
item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
}
}
}
}
It doesn't work
when you drop an item, the item spawns at the player's head
if (!item.getType.name().endsWith("_PICKAXE") return;
you need to wait a second or two, like I told you yesterday, for the item to actually get dropped onto the ground
anyone know how I can force the server to print full stacktraces? I legit am only seeing two lines, and it's not enough to trace my issue back
"... 40 more"
Are you using the Oracle JDK
yeah, OpenJDK 16.0.1
oh apparently those lines ommited are just the ones that are above this
Do I have to add onto the Bukkit scheduler I have to do that?
well..... thanks windows terminal
Can i mention Lua code here? idk what to do with this error
Usually only spigot & bungeecord programming help, but go for it
entities/gmod_wire_expression2/core/entity.lua:315: attempt to index local 'this' (a nil value)
Expression2 is used for creating lua chips in game
can you send me the code, and not just the error
yea sure
give me a min to load
@inputs
@outputs Eang:angle Speed Spd AD
@persist EArr:array [User,E]:entity W A S D Shift Space M1 M2 Speed [RanC,RanF,RanB,RanL,RanR]:ranger WS AD C
@trigger
runOnTick(1)
Mass = E:mass()
C++
User = E:driver()
W = User:keyPressed("w")
A = User:keyPressed("A")
S = User:keyPressed("S")
D = User:keyPressed("D")
Shift = User:keySprint()
Space = User:keyPressed("Space")
Speed = E:vel():length()
E = entity():isWeldedTo()
if(Space){
Spd = 0
}
elseif(Shift){
Spd = 100000000
}
else{
Spd = 30
}
E:applyForce(E:forward()*(W-S)*E:mass()*Spd)
if (A)
{E:applyAngForce(ang(0,30000,0)) }
if (D)
{E:applyAngForce(ang(0,-30000,0)) }
if(W){
E:applyForce(E:forward():setZ(-0.30)*(Mass^1))
if(Speed < 20){
#entity():applyForce(vec(0,0,Mass))
#entity():setMass(Mass/8)
}else{entity():setMass(1)}
}
if(S){
E:applyForce(E:forward():setZ(-0.30)*(Mass^1))
if(Speed < 20){
#entity():applyForce(vec(0,0,Mass))
#entity():setMass(Mass/8)
}else{entity():setMass(1)}
}
wiremod?
gmod addon
...40 more means that the 40 stack frames that were omitted have already been shown in the Caused by: blocks above
yes I figured that out
Does this look okay @wraith rapids?
@EventHandler()
public void onItemDrop(PlayerDropItemEvent event) {
new BukkitRunnable() {
@Override
public void run() {
ItemStack item = event.getItemDrop().getItemStack();
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!(item.getType().name().endsWith("_PICKAXE"))) {
return;
} else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
return;
} else {
for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
e.remove();
item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
}
}
}
}
}.runTaskLater(this, 20 * 3);
}
using a bukkitrunnable is redundant
use the bukkit scheduler instead
other than that it should be fine
I already have one that's set for every second for the flight enchant
no, i mean use the bukkit scheduler instead of bukkitrunnable
ohhh
Bukkit.getScheduler().runTaskLater(plugin, () -> { code here }, time)
instead of
new BukkitRunnable() { @Override public void run() { code here } }.runTaskLater(plugin, time)
the bukkit runnable one creates an anonymous local class, which is slower, less readable, and fills your jar with redundant classes
Oh
the bukkitrunnable one is used when you need to cancel a repeating task from within the task itself
in any other case it is useless
Like this?
@EventHandler()
public void onItemDrop(PlayerDropItemEvent event) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
ItemStack item = event.getItemDrop().getItemStack();
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!(item.getType().name().endsWith("_PICKAXE"))) {
return;
} else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
return;
} else {
for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
e.remove();
item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
}
}
}
}
}, 0L, 70L);
}
almost
use a lambda instead of creating an anonymous local class implementing Runnable
() -> { code here }
instead of
new Runnable() { @Override public void run() { code here } }
Oh
the reason you can't do that with a BukkitRunnable is because it's not an 1 method interface, so you can't substitute it with a lambda
What did I do wrong here?
@EventHandler()
public void onItemDrop(PlayerDropItemEvent event) {
Bukkit.getScheduler().runTaskLater(this, () -> {
@Override
public void run() {
ItemStack item = event.getItemDrop().getItemStack();
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!(item.getType().name().endsWith("_PICKAXE"))) {
return;
} else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
return;
} else {
for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
e.remove();
item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
}
}
}
}
}, 0L, 70L);
}
yeah, tell us. what did you do wrong?
or more like: what does not work like intended?
let me reiterate
() -> { code here }
instead of
new Runnable() { @Override public void run() { code here } }
look at your code
Oh
you're doing
() -> { @Override public void run() { code here } }
IntelliJ still shows the runTaskLater as couldn't resolve
Bukkit.getScheduler().runTaskLater(this, () -> {
ItemStack item = event.getItemDrop().getItemStack();
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!(item.getType().name().endsWith("_PICKAXE"))) {
return;
} else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
return;
} else {
for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
e.remove();
item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
}
}
}
}, 0L, 70L);
runTaskLater only takes one number
you are trying to call runTaskTimer
which takes 2 numbers
I still don't know how I feel about proper enchantments vs PDC based enchantments
proper enchantments do have some advantages
I assume they work with books and the enchantment table automatically
and anvils and the grindstone and all that jazz
Yeah that does seem nice
i see little reason to use the pdc for it beyond just the ease of use from not having to fuck with the registries and shit
@wraith rapids 70L should be 3.5 seconds, right?
yes
what's 70 divided by 20
Okay, making sure it goes by ticks
So something with the book check is broken
yay
They way i'm using them right now they aren't really designed to be obtainable through normal means, so I guess PDC works well for this
registering them in the bukkit enchantment registry doesn't actually register them in nms under the hood, I don't think
i'm not sure what manner of things that affects, and I haven't seen anyone actually register them in nms, just always in the bukkit registry
NMS is pain
yeah but you'd think something would require it to be in the nms enchant registry
it's strange that nobody does that
And I'm still salty over the private static final ImmutableLists
Indeed, I miss the dodgy reflection on the modifiers
I wish spigot had AccessTransformers
i might have to fork paper for 1.17 for my server
Someone bug Aikar to add Mixins :p
with the way reflection is going and how aikar fucked up the timings backend, I don't think it's possible to do per-entity timings handlers anymore at all
I'm literally a dumbass
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
there is no way (without caching the block interactions) to get the block of an inventory, is there?
I was in creative
and I am very fond of my per-entity timings
getting the inventoryholder and casting to blockinventoryholder and getting location might work
or something along those lines
so I'm trying to make some particles rotate around a certain point, but for some reason, it's rotating around 0,0,0 in the world
ok true, and I guess that would eliminate any custom inventories as well, right?
that's what it looks like, and the cursor is centered on 0,0,0
you forgot to add the rotated location to the origin location
What scope does Bukkit.callEvent() call to. ie can an event that you have made urself by just extending Event be listened to by any other plugin? I thought it could but some1 said it couldnโt
a custom inventory could I guess set its inventoryholder as a blockinventoryholder
yes
pretty sure callevent works for all things extending event
i don't remember there being a specific variant for custom events provided by plugins
So it calls it so that anything can listen for it?
yes, anthing that is registered to listen to it
Ok
it asks the static HandlerList of that class about which EventHandlers are registered to it
and then invokes those handlers
//this is where the player is looking
Location loc = res.getHitPosition().toLocation(player.getWorld());
//this puts it up 3 blocks on y axis
Vector locv = loc.add(0,3,0).toVector();
//this displays the particles from the loop of coordinates (that should be added)
loc.getWorld().spawnParticle(Particle.HEART, locv.clone().add(new Vector(x,y,z)).toLocation(loc.getWorld()), 1);
locv.rotateAroundY(21.5);
let's just hope nobody does :d
Is there a way to stop this ( like a private event )
make the constructor private ig
Makes sense - ok thanks
Write your own event registry
also possible but maybe a bit overkill