#help-development
1 messages · Page 1847 of 1
When patching I just run CB
but can't you just use the main jar anyway?
then I have no idea. does it work when using other particles?
havent tried yet let me see
?
I think you can compile it back to spigot using buildtools with --dont-update
(After committing your changes)
normally you DO NOT want to run buildtools but just compile spigot using maven
it seems to work fine with the heart particle but it has an animation so i wonder if its just a set animation for the particle
theres some extra data for the function im gonna try set to 0
probably that fire particle just has random movements builtin
:3
worked, thanks :)
do u know why just mvn clean install doesn't work anymore?
it should work. any error msgs?
¯_(ツ)_/¯
no errors
and where's the problem?
Probably because of the bootstrap stuff
this happens when I run
the one without bootstrap or remapping
You need to run the bootstrap one
mvn creates this file:
spigot-1.18.1-R0.1-SNAPSHOT-bootstrap.jar
it should run fine
inside SPigot/Spigot-Server/
👍
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("ProSword"),new ItemStack(Material.DIAMOND_SWORD));
sr.shape("DDD"
,"DSD"
,"DDD");
sr.setIngredient('D',Material.DIAMOND);
sr.setIngredient('S',Material.DIAMOND_SWORD);
}
i have tried that code now but it does not work and does not show any error also
Well yeah, you need to add the recipe separately at startup
And then validate the ingredients using the event
ohh
wait whut?
you should not create a new crafting recipe in every PrepareItemCraftEvent
as Coll said: create the recipe ONCE on startup
buuuut
I already said:
this won't work
and also wtf
you use a minecraft namespaced namespacedkey
you should use your plugin instead
you should be able to
You would create a recipe with just the bare items at startup
any error message?
And then validate they have the data you want in the event
The bare recipe is just so the prepare craft event actually triggers
if always gets called when the matrix is changed, yes
let me double check, but im 99% sure
error: unmappable character (0xE9) for encoding x-windows-950
my intellij doesn't want to open lol. but yeah I'm 99.9% sure because I'm using it in one of my plugins
event.getPlayer().kickPlayer(("雲端\nReason for ban >> "+jsonObject.get("response").getAsJsonObject().get("reason").getAsString()));
that's strange. then it seems like the client simply doesn't like you for using chinese symbols
I don’t think that’s the client
lol i am newbie everything is goind above the head but i am still try to undertstand and catch everythign
Looks like you need to change the encoding in your IDE
is that message appearing on compiling, or only when you run the code?
It still does not display properly in Minecraft
that's a zero!
I try it now
?
event.getPlayer().kickPlayer(("\u96f2\u7aef\u9632\u8b77\u7cfb\u7d71\nReason for ban >> "+jsonObject.get("response").getAsJsonObject().get("reason").getAsString()));
Is this right?
try it
does yml support utf8? might be worth trying to put the messages in a yml file so you don't need to escape every single character
and this solution (assuming yml does support utf8) would let you keep your sources ansi also
It does if you save it as such
(and would also make your plugin easily convertible to whatever language instead of hard coding the messages as chinese)
i think i found how to make custom r ecipes
how will i give the item a colored name
using setDisplayName
ChatColor
it should, and afaik you can just use the reset color to remove the italics on custom named items
ok
your link was missing a few
lol nvm, i just didn't scroll down enough like an idiot
can i use font tag and color tag together?
format and color? yeah
what does fint mean? the format ones? yeah
*font
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
public class itemManager {
public static ItemStack proSword;
public static void init(){
}
public static void createProSword(){
ItemStack item = new ItemStack(Material.DIAMOND_SWORD,1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§4Pro Sword");
meta.addEnchant(Enchantment.DAMAGE_ALL,5,false);
item.setItemMeta(meta);
proSword = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("pro_sword"),item);
sr.shape("DDD"
,"DSD"
,"DDD");
sr.setIngredient('D',Material.DIAMOND);
sr.setIngredient('S',Material.DIAMOND_SWORD);
Bukkit.getServer().addRecipe(sr);
}
}
```This Time I did it in the class with everything said but again its not working 😦
public void onEnable() {
itemManager.init();
}
your init method calls nothing
beuh i am so dumb
lets go
its working
thx to everyone who helped me making is
tysm
😄
hey all, i have kind of a weird problem:
im making a trap plugin and im trying to make a trap that encapsulates the victim in a 3x3 invisible wall that only theyre affected by and blah blah blah i have all that stuff down but i have a class for timed events and a class for the trap itself. before when i made an explosion trap it was pretty simple, the victim steps on the trap and it passes a location and a timer to the timed event class and after the timer drops to 0 then an explosion is created at the location, but this one is kind of weird. I need to pass 3 objects, a location, an int for the timer, and a player, but i havent found a way to do it. i used a hash map for the explosion trap but you obv cant fit 3 values into a hash map
im gonna try put a hash map inside a hash map wish me luck kekw
I mean encapsulate the data with a class
If you’re on newer versions, you can even use a record
lmfao i put a hash map in a hash map boys
bro i have completed the code to get shaprneed 5 dia sword after doing a specific recipe
now how will i make it so that it gives sharpness 6 or more then it
That’s a terrible design
as said you should encapsulate said data in a new class and pass that type to the V type parameter
if i do using addenchants it just removes the enchants
true
any solutions for that?
Use addUnsafeEnchantments iirc
pretty sure you need to use addEnchantment
Something with unsafe
i did but i want to add sharpness 6
declaration: package: org.bukkit.inventory, class: ItemStack
when i add that
is just removes all the enchants
if i add shapness 5 then it add but if its sharpness 6 nothing happens
unsafe enchants?
Check the link I sent
I can add unicode to kick message
Yes you can but not on ItemMeta if you’re observant
String msg= MessageFormat.format("\u96f2\u7aef\u9632\u8b77\u7cfb\u7d71\nReason for ban >> {0}",jsonObject.get("response").getAsJsonObject().get("reason"));
Yeah although you need to make sure your compiler compiles with UTF-8 encoding or smtng
[16:21:05] [defaultEventLoopGroup-5-1/INFO]: [Geyser-Spigot] whes1015 從 Java 伺服器中斷連線,原因為 雲端防護系統
Reason for ban >> "\\u5916\\u639b"
the problem is my unicode is \u5916\u639b
Or whatever Json lib u use
It always display \ \u5916\ \u639b
System.out.println(jsonObject.get("response").getAsJsonObject().get("reason"));
[16:21:04] [Server thread/INFO]: "\\u5916\\u639b"
Try to append .replace("\\\\","\\")
So is Gson's problem?
can i add using itemstack?
Might be
Yes
Send the code and never say not working, specify what does not work and what the wanted result is rather
sorry for not specifying
No worries but just for any future references:)
ItemStack item = new ItemStack(Material.DIAMOND_SWORD,1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§4Pro Sword");
item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL,6);
item.setItemMeta(meta);
proSword = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("pro_sword"),item);
sr.shape("DDD"
,"DSD"
,"DDD");
sr.setIngredient('D',Material.DIAMOND);
sr.setIngredient('S',Material.DIAMOND_SWORD);
Bukkit.getServer().addRecipe(sr);
}
```
It display correct but didn't change to chinese
ok 🙂
Wym by that :0
Oh yes, move the addUnsafeEnchantment under item.setItemMeta(meta);
It’s probably a bit weird to understand why that matters right now but ItemMeta is actually not a part of the ItemStack
[16:32:33] [Server thread/INFO]: whes1015 lost connection: 雲端防護系統
Reason for ban >> \u5916\u639b
ok
yay it worked
🙂
thx
👍
Actually it’s a bit more complicated now when I think of it
But how does your json look
Chances are you can read your json with utf8 encoding and get it to work that way
@analog prairie
So if you could share the code where you read the json file would be amazing
also how to make it so that they could only give shapneed 5 di amond sword for recipe and not any other diamond sword?
ItemStack ingredient = …;
sr.setIngredient('T',new RecipeChoice.ExactChoice(ingredient));
I had dm you
Thanks
I use UTF-8
so do constructors not work in spigot or am i just fucking stupid
They work
public class TData {
public static Location location;
public static int timer;
public TData(){}
public TData(Location location_, int timer_){
location = location_;
timer = timer_;
}
}
this is probably the simplest constructor ever but when i make a new TData object and try and use it like
Remove static
i need static
No you don’t lol
oh aight
don't do this (Location location_, int timer_)
_ is no longer valid in identifier names
I'm not sure, I think it's because they're used as keywords in later versions
does org.bukkit.particle; not exist i cant import it
Anyway
You should remove static.
yeah i did
Yeah they removed the possibility of using $ in variable names iirc
oh really?
dang
Ye sadge
:(
anyone know
So this pattern is what is called a DTO (data transfer object)
In Java, there's a very common way to define properties, which are getters and setters
Essentially, instead of allowing people to directly access your fields, you use methods to retrieve and set the value of the field
This is mainly to prevent binary incompatibilities as I understand it?
example:
private final String name;
...
public String getName() {
return name;
}
If we were to refactor the above code to be conventional.
public class TData {
private /* final */ Location location;
private /* final */ int timer;
public TData() {
// this.location = <default here>;
// this.timer = <default here>;
}
public TData(Location location, int timer) {
this.location = location;
this.timer = timer;
}
// Your getters here.
// If you didn't uncomment the above code, then your setters would also be here.
}
Note: This is conventional, but not pretty. Java is not meant to be pretty.
anybody cane help my with towny plugin'
If you want a pretty language, go look at Kotlin 😉
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
i tried it but nothing happened?
That was just a sample code
You need to understand it and apply what I did just a little bit different
is it possible to make my new item with all those enchants and put it in ingredent?
Think so
?
i was typing the wrong spelling xD
You can’t import a package
huh
you could use org.bukkit.particle.*; tho that’s a bit slower
Ideally just import the class
Well then that’s not a valid package
you know classes are case sensitive in terms of name
Actually a lot of stuff is in programming generically speaking
Which spigot API version are you using @sacred mountain
tried that didnt work
im just using my 1.8.8 server jar
Smh
for referenced libraries

I guess that might be the reason
i'm literally just tryna fix some stuff from another plugin, im not a great dev at all
idk whats wrong with ti
@ivory sleet did 1.8 even have particle API?
that will be a rip if it didnt
Good reason to update
well i cant really do that rn
is there any way to get a particle api in 1.8
like an external
I don’t think so 🌚
Because ?
whole server is almost done on 1.8
its just this one class that im trying to fix without removing it
should i bother downloading particle api plugins and using those
Yeah better than committing yourself to nms
2bad
the maximum limit of enchants using commands is 32767 so unsafe enchants have the limit ?
In newer versions 255
ohk
Hey, how do I use NMS to show a block as "cracked"?
Step 0: you use the api
declaration: package: org.bukkit.entity, interface: Player
ty
🥲
Hi Conclure just to know, have you already any tips?
Oh yeah link that thing
Don't worry 😂 https://github.com/Mr-EmPee/CommandManager
Can you remove the minecraft:paper and NBT lore?
what was that text file thing that you could save data to like strings and ints and shit
i forgot what it was called
but i need to use it lol
It's a client setting ... I think F3 and B
Can I display color on console?
you could change the itemstack thru packets probably
Gets the brand of the currently connected server. May be null if the server hasn't yet sent brand information. Server brand information is sent over the {@code MC|Brand} plugin channel, and is used to identify modded servers in crash reports.
How do I change the server brand (which packet/plugin channel)?
Will that change the server brand?
Or just the f3 brand
The F3 brand is the server brand i think
I think the F3 Brand is the client
which, unless you have a mod that changes it or have a custom client, it is by default Vanilla
don't have the client loaded but I am sure someone can check really quick
if it says anything other then Vanilla on a spigot server, then we know its not from the client 🙂
difference between clients and launchers
anyone know why getConfig().set("Traps.ExplosiveTraps", null); isnt working? im trying to reset the entire path
nvm i figured it out
anyway
anyone know how to iterate through a config like this:
Traps:
ExplosiveTraps:
'1':
Location:
==: Vector
x: 26.0
y: 66.0
z: 100.0
PlacedBy: f780f203-cf11-4416-9e07-9ec21b37e476
'2':
Location:
==: Vector
x: 30.0
y: 67.0
z: 109.0
PlacedBy: f780f203-cf11-4416-9e07-9ec21b37e476
and get the vector values and uuids?
back into a hashmap i mean
or at least get the length of all the '1' '2' so i can iterate through the config directly
You can save the length of this in the config while setting it too...
Thanks, F3 + B is Hitbox, the tooltips is F3 + H
oh true
lol didnt think about that
well, there is also the server brand
ofc you can't change the client brand
You can change the server brand in F3 but it is sended in the moment the player joins ... So you need to catch the packet there and modify it
I wonder if it is possible to check where an arrow hit a player?
there is a plugin to hide that
Like the height or the back/front/left/top?
I'd say the height would be enough.
Like... is it in the player's head, or in his legs
Not that easy and not accurate all the time but it is possible
does getOfflinePlayer work even if the player is online
i get that it says offline player
but i just need to know so i can get the uuid
Yes
Yeah, but it will give you the online player
alr ty
anyone know anything about effectlib
im having trouble doing some stuff
i dont know where to add parameters into the code after reading the wiki
anyone know why UUID tempID = Bukkit.getOfflinePlayer(getConfig().getString("Traps.ExplosiveTraps." + iter + ".PlacedBy")).getUniqueId(); isn't working? the error says that its returning null even though it shouldnt be, i can literally see it there in the config
Just curious... Why exactly don't you just save the uuid in the config?
i do but if u try set tempid directly as the string in there it rejects it
Did you try UUID.fromString, or did you just put a string there?
i just put the string there
If you use Bukkit.getOfflinePlayer with a string, it's assuming you entered a name, not a uuid
whats fromstring
oh really?
thats not sarcastic
it looks sarcastic
UUID.fromString(yourUuidAsAString)
No, it's not sarcastic
You're welcome
is anyone on mc 1.18.1 rn? i need u to hop on the server so i can test smth itll be like 2 seconds
send me
How can I send the crack animation to a few blocks at the same time? everytime I send a new crack animation the previous one disappears..
Hello! I am trying to disable the fact that a tripwire gets powered when you step into it.
I looked at the spigot source in buildtools and here is what I found (it's from CraftBukkit):
// CraftBukkit start - Call interact even when triggering connected tripwire
if (flag != flag1 && flag1 && (Boolean)iblockdata.get(ATTACHED)) {
org.bukkit.World bworld = world.getWorld();
org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
org.bukkit.block.Block block = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
boolean allowed = false;
// If all of the events are cancelled block the tripwire trigger, else allow
for (Object object : list) {
if (object != null) {
org.bukkit.event.Cancellable cancellable;
if (object instanceof EntityHuman) {
cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
} else if (object instanceof Entity) {
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
manager.callEvent((EntityInteractEvent) cancellable);
} else {
continue;
}
if (!cancellable.isCancelled()) {
allowed = true;
break;
}
}
}
if (!allowed) {
return;
}
}
// CraftBukkit end
As you can see, cancelling PlayerInteractEvent and EntityInteractEvent should be enough
@EventHandler
public void tripwireEvent1(PlayerInteractEvent event) {
event.setCancelled(true);
Logs.logInfo("triggered 1");
}
@EventHandler
public void tripwireEvent2(EntityInteractEvent event) {
event.setCancelled(true);
Logs.logInfo("triggered 2");
}
Unfortunately, this code doesn't seem to work: event is not triggered when I step into a string (it is if I click on it of course)
Any idea why?
I'm not sure never dealt with this but I can only give what I think can be the solution.
Try saving the entity the player is interacting with and save it as a tripwire, after that change the tripwire's state
What entity are you talking about?
I am trying to understand why the event is not triggered
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction() == Action.PHYSICAL) {
if (e.getClickedBlock().getType() == Material.TRIPWIRE) {
p.sendMessage("you hit a trap!");
}
}
}
I think you can change it to any entity as well
This won't help, as I said it is not triggered
dumb question but, did you register the listener?
yes, as I said it works if I click on it
Happens to me a lot that's why I'm asking
PlayerInteractEntityEvent try using this event maybe
This event is not triggered according to the code I sent
here
Tripwires are not entities
Yeah now I understand, it's pretty weird since it even says "If all of the events are cancelled block the tripwire trigger, else allow"
Does someone know what is the probable cause here? So I make armor stand follow player's head movement, and suddenly the armor stand stops following player's head movement when player is riding something.
yeah exactly
do you know where I could report this issue to spigot team?
The armor stand rotates the same angle your head does but when you get on the horse your head rotates to the horse's head and the armor stand doesn't that's when the problem is starting.
Try rotating the armor stand to the horse's head angle when the player gets on it
Not sure, maybe try tagging one of them
Does mining fatigue -1 let's the player hand animation move the same speed without actually breaking the block?
in 1.8 it used to work but I'm now using 1.18
The player follow horse head movement?
The head's angle changes to the horse's head angle but the armor stand stays according to the player's head angle before you get on the horse
Okay, I'll try to use the horse's yaw.
can anyone help me?
why not trying?
I actually asking because I tried maybe it doesn't work anymore and maybe I did something wrong..
public void addSlowDig(Player player, int duration) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, duration, -1, false, false), true);
}
that function gives the player the mining fatigue and I do receive mining fatigue ingame
what are you trying to do?
setWorld
Bukkit.getWorlds().get(1) iirc
index 0 is overworld, 1 is nether and 2 is end, rest is custom worlds
how do i get the world index of a block
i think it might be in the location property
would it be a good idea to start the hikari connection pool when i need a connecion, not when the plugin starts up?
Still, the armor stand head movement isn't following the horse head movement.
https://paste.md-5.net/adaqajeruq.cs
hello i have a question about wiki.vg
it shows protocol specifiactions and stuff about 1.18
but i want info about release 1.9.4
https://wiki.vg/Entity_metadata#Player for example this
is the if check unneccesary?
yes, you don't need the length check
oki
when iterating, you don't need to check length
Google time Website machine
When is the itemMeta of an ItemStack null?
Hey, how can I put the equivalent to mining fatigue -1 of 1.8 in 1.18?
I want the player to move the hand like he is mining but won't actually damage the block, I know I can cancel block damage event but on the client side he will break the block..
In 1.8 I could give the player mining fatigue -1 and the hand would move the same speed but he won't damage any block.. I think they removed that in 1.18
In 1.18 you can send block damage to 0 all the time
with the player.sendBlockDamage(location, 0f);?
currently I'm using this but to change the animation, I'll send you the code, 1 sec
private ArrayList<CustomBlock> blocks;
@Override
public void onEnable() {
this.blocks = new ArrayList<CustomBlock>();
getServer().getPluginManager().registerEvents(this, this);
}
private CustomBlock exists(Location location){
for(CustomBlock block : blocks){
if(block.location.equals(location)) return block;
}
return null;
}
@EventHandler
public void onInteract(PlayerInteractEvent event){
Location location = event.getClickedBlock().getLocation();
CustomBlock block = exists(location);
if(block != null){
block.incermentDamage(event.getPlayer(), 0.05f);
}else{
blocks.add(new CustomBlock(location, 0f));
}
}
Main ^^
public class CustomBlock {
public float dmg;
public Location location;
public CustomBlock(Location location, float dmg){
this.location = location;
this.dmg = dmg;
}
public void incermentDamage(Player player, float damage){
this.dmg += damage;
if(dmg < 1f) {
player.sendBlockDamage(location, dmg);
}
else
player.sendBlockDamage(location, 0f);
}
CustomBlock^^^
This is just a test so I don't care if the main and the listener are the same class
So with this code if I cancel the interact event the block would break and then it would cancel the break, but on client side it would show the crack animation going all the way
I know I can send the block crack animation through NMS but I couldn't find how..
Playerinterscct gets called just once
Playerinterscct event*
You will need to check if the player clicks something else and if not send no block DMG all the time
Also mining fatigue 255 will slow down the break animation ?
I'll try the mining fatigue 255, but I didn't understood what you said about the playerInteractEvent, currently I'm testing a perfect situation where the player doesn't click anything else, when I long left click the block will break like in vanilla minecraft but since the server cancelled the event the block won't disappear, I don't want the block to even break on client side.
@cold field anyways the code is better
You could still extract the data transfers themselves from the manager logic
they don't damage the block but the player's hand is no where to be seen lol
Was that meant for me? or EmPee?
Empee
I saw people use protocolLib for sending packets, is it better than NMS?
Yes
And where can I find the full api?
Ok thanks for the review. What do you mean? Is it possible that you mean removing the CommandManager class to use the CommandRegisterService directly?
what are we reviewing?
I want to review something 🙂
He was reviewing my code. I've made a lib that expose brigadier compatible from 1.8.8 to 1.17.1
If you want the link is https://github.com/Mr-EmPee/CommandManager
can a final HashMap be updated
yes
the final hashmap is the instance not the elements in the hashmap
@EventHandler
public void onInteract(PlayerInteractEvent event){
Location location = event.getClickedBlock().getLocation();
PacketContainer fakeExplosion = protocolManager.createPacket(PacketType.Play.Server.EXPLOSION);
fakeExplosion.getDoubles()
.write(0, location.getX())
.write(1, location.getY())
.write(2, location.getY());
fakeExplosion.getFloat().write(0, 10f);
try{
protocolManager.sendServerPacket(event.getPlayer(), fakeExplosion);
}catch (InvocationTargetException e){
throw new RuntimeException("Cannot send packet " + fakeExplosion, e);
}
}
anyone knows why it doesn't create an "explosion"?
Why are you using Protocollib for Particles
how can i place a player head and set it's owner?
Bukkit.getScheduler().runTask(BlockRegen.getInstance(), () -> {
block.setType(regenerateInto);
if (block.getState() instanceof final Skull skullState) {
skullState.setOwningPlayer(Bukkit.getOfflinePlayer(preset.getOwnerUuid()));
}
});```
i put this together but it doesnt work (regenerateInto = Material.PLAYER_HEAD)
getState returns a copy. To apply your changes call update
not just update... setBlockState and then update maybe ?
I will review it later if that is ok
however caveat, I will only review it for 1.17+
only because I am not a fan of developing for older versions, however just because I am not a fan of it, doesn't mean I should punish/critique harsher on others for doing so even if I would prefer if the majority of devs would stop supporting outdated versions
if your repo is setup in a way that makes it easy to review code for differing MC versions I will only critique on the code for 1.17 🙂
Just letting you know ahead of time so that when I give you my review it isn't confusing XD
should i load users from the db in the pre login event or just on join?
never saw someone using instanceof with final heh
they just made the variable final tho
right?
yea looks weird
not really
AsyncPlayerPreLogin
as far as i remember
ive seen smth like this in a forum or smth
yea was just asking
hey i wanted to ask that i was working on crafting recipe but i have to make similar crafting recipe for 5 to 6 items so is there any way to do it faster rather than typing the whole code again and again
???????
just use a method
to create the recipe
pass in the things that are different from each item to another in the params
is it possible that i make a varialbe 'x' thne use it every where in the method then i replace teh x with the string of the item?
u mean like
x as a param?
then just method(x);
btw u shouldnt name variables 1 letters
ok
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
pre-login and the reason for this has to do with wait times
if I remember right, in the pre-login phase you can do all the stuff you want to and have a fairly long time to do so before connection gets dropped
and if for some reason the DB stuff isn't able to get fetched for whatever reason you can just terminate the connection
if you did this in the on Join phase, it has the potential of causing the server to lag, and because we already passed some protocol connection stuff, you have a shorter time to do stuff before the server automatically terminates the connection
and if the DB server stuff couldn't be fetched, they could potentially be stuck waiting on the connection to terminate
Ok get it. The problem is that I've used reflection to make it compatible with older version. I really wanted to avoid using reflection for 1.17 (Thanks to nms repackaging) the problem is that some classes has been compiled with java version 16+ and I can't compile the lib with java 8
alr thanks
alright I will still look then to see how it looks. I am not a fan of reflection either, but I know it 😛
sometimes it is just necessary
reflection that is
Ok, thanks I really appreciate it
anybody
I'm asking again, anyone know what's the equivalent of 1.8 mining fatigue -1 on 1.18?
I want to make it so that the hand animation moves the same as if the player doesn't has a mining fatigue but at the same time that the player doesn't damage the block on client side
Hi, I have a problem with PlayerInteractEntityEvent
These is my code
public void onInteract(PlayerInteractEntityEvent event) {
if (!(event.getRightClicked() instanceof Player)) {
return;
}
Player player = event.getPlayer();
Player target = (Player) event.getRightClicked();
if (player.getItemInHand().getType().equals(Material.BLAZE_ROD)) {
if (player.hasPermission("gtautils.cuff")) {
if (Main.cuffs.contains(target)) {
Main.cuffs.remove(target);
player.chat("/uncuff " + target.getName());
} else {
Main.cuffs.add(target);
player.chat("/cuff " + target.getName());
}
} else {
player.getItemInHand().setType(Material.AIR);
player.sendMessage(Utils.getColorizedConfig("noPermission"));
}
}
}
// I have a HashSet of Player in my Main class too
Problem is when I Right click on anyone, plugin runs both if and else codes.
all of this
Thanks
that event runs for the mainhand, and then sometimes also the offhand
So how I can check item in player's hand in another method ?
the event has a getItem() which returns the itemstack in the hand, regardless of which hand it was
😔
umm
wish i could help, i don't remember anything about 1.8, it was quite a long time ago
Do you know maybe how I can make sure that the hand moves normally (when you mine) but you don't damage the block, trying to figure it out with protocol lib but I'm not even sure if it'll do the job lol
what are you showing in this image?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getItem()
earlier today/yesterday someone was saying something about that sort of thing if you scroll up quite a bit.
Its a short time I started to coding, so ...
*PlayerInteractEntityEvent
I think it was someone trying to help me lol
ok, event.getItem() will return an instance of an Itemstack
what
the getHand
I answered this
unnessecary check
if (Main.cuffs.contains(target)) {
Main.cuffs.remove(target);
cuffs.remove(target) will return a boolean whether or not it can be removed or not
thanks
like this ?
Can anyone help me understand protocol lib? I'm reading the wiki and having a bit of a issue understanding
what is cuffs?
what exactly is the problem ?
you create the packet, write the data that the packet needs and then send it ...
the mining speed penalty ?
you cant
unless you add some speed / break the block before it should break with calculations ...
In the wiki they give packet ID, how do I use that ID?
i'm having a player field somewhere in a class that extends bukkitrunnable, when the user leaves the server the runnable will be cancelled, will it be able to be gc'd?
manipulate packets
why shouldnt it?
what id do you talk about ?
i think it is the packet-id that identifies the packettype
also because its an inner class
and that outer class instance is stored in a map
I see, so for example if the wiki shows "Packet ID 0x09" it doesn't really concerns me right?
inner class just means that it belongs to the scope of the outer class
not rly
a HashSet of Player in Main class
dont make fields public tho
so remove the second remove
why tho
I did thanks, but the main problem isn't solved yet
you dont want to expose them
ok you mean for public uses ...
your problem is, that it runs once per hand
check if the hand is of OFF_HAND and return if so
https://prnt.sc/24o9pun
In protocollib if I have this packet, to change the ID I do:
packet.getIntegers().write(0, 1)
and to change the stage I do:
packet.getBytes.write(0, (byte) 1)
or did I understood in incorrectly, because if I didn't then how do I change the location?
what he's trying to say is, that there is a thing called encapsulation which belongs to OOP
having public fields in such a context breaks the concept of OOP kinda
Sorry for asking too many question about this I just feel a bit lost here XD
packets are a pain
in general a good idea but not important for private usages tho
its a nice to have
I used player.getInventory().getItemInMainHand().getType().equals(Material.BLAZE_ROD) to check item in player's hand, and if it will run twice for each hand, the off hand is empty of BLAZE_ROD, so I don't understand why
it is. its like having 3 lego stones but not stick them together
bad metaphor but the point should be clear
position is mostly 3 integers ... so maybe setInteger(1,x),setInteger(2,y), setInteger(3,z)
i'm always thinking if you really want to use something as obj.myfield make it like a method so you can call obj.field()
the event provides a #getHand() method and you are just checking the mainhand. when the offhand is called, the mainhand still has the item
but yea i'm doing strange things sometimes
I see, thanks.. I do think it's doubles as seen here: https://dev.bukkit.org/projects/protocollib/pages/tutorial on the sending packets section
2 things:
- how can i create a particle effect?
- how can i raycast?
try and error ... simple enough to test a few things with protocollib
yep, thanks a lot!
World#playParticle or smth
Entity#rayTrace or smth
perfect, tysm!
whats the spigot docs cmd?
?jd
?jd World#spawnParticle
oh
how will i use methind in plugin java cuz i am creating similar crafting recipies so i dont want to reapeat a code so much?
uhm
?jd
?jd method
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
@EventHandler
public void onInteract(PlayerInteractEvent event){
Location location = event.getClickedBlock().getLocation();
for(int x = -2; x < 3; x++){
for (int z = -2; z < 3; z++){
PacketContainer blockBreak = protocolManager.createPacket(PacketType.Play.Client.BLOCK_DIG);
blockBreak.getBytes().write(0, (byte) 5);
blockBreak.getIntegers().write(0, x + z);
blockBreak.getDoubles().
write(0, location.getX() + x).
write(1, location.getY()).
write(2, location.getZ() + z);
try{
protocolManager.sendServerPacket(event.getPlayer(), blockBreak);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
I tried something pretty simple, but it says that the error is in line
blockBreak.getBytes().write(0, (byte) 5);
here is the document for this packet: https://wiki.vg/Protocol#Block_Break_Animation
or maybe I am using the incorrect packet
i knwo basic of java but i am new to plugin devlopment
i know that but idk how to implement in plugin devlopment
It's the same
isnt there a method to send the player block break in bukkit?
just create a method that does some stuff and call it
like sendBlockBreak or sendBlockDamage
i am making a code so that if i add diamond blocks around the diamond armour and it should give the armour with prot5 and that part is working but how will make into method thats the problem
cuz as far as i know we can put variable in method
and armour is a defined funtion
Player#sendBlockDamage?
where do gradle builds get output to?
maven usually outputs it in a target folder in the project
There is but it can show only 1 block at a time and you need to do it per player, so if I want to show 10 block that are half broken to 2 players well.. you can't with that
I'm suffering lol
been trying to figure this out all day
instead of ItemStack item = new ItemStack(Material.DIAMOND_HELMET)
what should i w rite in teh mothod
so that i could replace the called method with the armour i need
maybe its BLOCK_BREAK_ANIMATION? @trim crystal
that matches up with the 0x09 packet id
Thanks, I'll check it
take a material as argument?
Yeah I figured I wrote the incorrect packet
rip
i think u were also sending a client packet from the server so
lol
or trying to
oh lmao, I'm pretty new to this XD
Gives me this error everytime I interact with a block
on phone cant see that
oh lol, I have this line as well: [ProtocolLib] Loaded class RPrison.rprison.Rprison from Rprison v1.0-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.
?
Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type byte exists in class PacketPlayOutBlockBreakAnimation.
This is the main error here
uhh
maybe try writing in the order of packet fields on wiki? idk
so write the int, then the location(x3 doubles, or int depending on how it wants loc?), and then the byte
never used protocollib either so shots in the dark rn
rip
yep XD
will Entity#remove function even if the entity is not in a loaded chunk?
Entity#remove marks it for deletion
which will not happen in an unloaded chunk
is the String::replace to prevent SQL injection?
String statement = "SELECT * FROM playerdata WHERE player_id='{id}'";
pStatement = connection.prepareStatement(statement.replace("{id}", uuid + ""));```
just posted a thread on the forum.. let's hope someone will save me lol
das not how prepared statements work
;listen
just
learn java
okay
u wouldnt need to waste time for such a simple task if u knew java
private void nameThisWhatever(Material material) {}
actually replace void with the class name
was it shaped recipe
or smth
wait nvm
Is there anyone here that knows how to use protocollib?
Yeah
how would i save a list of channels (strings) in a database?
i was thinking of saving it as one string with a delimiter
i could make a new table with channels and inner join it with the users, goes kinda brrr
.
does this looks clean lol
public User getUser(UUID uuid) {
return userCache.values().stream().filter(u -> uuid.equals(u.getUuid())).findFirst().orElseGet(() -> {
String sql = "SELECT * FROM playerdata WHERE uuid='" + uuid + "'";
try (Connection conn = Database.getInstance().getDatasource().getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ResultSet rs = ps.executeQuery();
if (rs.next()) {
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
});
}
userCache is a map<uuid, user> tho
even if uuid is UUID, i would recommend using PreparedStatement#setString instead of concatenating
oh uh lets assume its better
also userCache.values().stream().filter(u -> uuid.equals(u.getUuid())).findFirst() time complexity is O(n) (linear)
instead, you could use uuid as key
so like this and then replace it
String sql = "SELECT * FROM playerdata WHERE uuid='?'";
xd i was trying to do some stream stuff
ah i can remove the ' '
also whats the best way to save a players playtime to a db? rn im saving an int with the total minutes they have played since they joined?
if i have a home list in a player data file like this:
Homes:
HomeName:
Location: ....
AnotherHomeName:
Location: ....
how do i get the amount of homes, when i do getStringList(Homes).size() it returns 0
its not a list
a stringlist == ```yaml
key:
- 'value1'
- 'value2'```
do getConfiurationSection("homes").getKeys(false).size()
is there no api for leashing entities to fenceposts?
I can get the leashholder entity
but I can't do anything with the api equivilent to this: /summon pig ~ ~ ~ {Leashed:1b,Leash:{X:32,Y:32,Z:32}}
Yes
also is it possible to return in a HashMap::forEach?
doesnt work so i guess no
Map.Entry goes brr
lambda expressions do have their caveats
true
ik its about java not exactly spigot, but how to make timeout, like 1 second after
runtasklater
isnt that a responsability for the fence or the leash itself?
playerConnection now is "a" or smth like this
sounds like a remap issue
i think he does not use the mojang remappings ...
best move
efficiency is something else i guess xd
Since userCache is a map you should just do userCache.get(uuid)
The whole point of a hashmap is the key based access
Otherwise you could just be using a list
did i just....
do this..
bruhh its because it was an arraylist first and i didnt change it
you could also use computeIfAbsent
The .get() is the main reason to use a hashmap, it gives you amortized constant time access by key
You wouldn’t want to use computeIfAbsent here
return userCache.computeIfAbsent(uuid, k -> {
// execute query to database
return user;
});
my english is broken
Are you synchronizing access to userCache
Or how are you maintaining thread safety
i'm not using it on multiple threads
You’re doing database calls on the main thread??
yea i was planning to do it async
You have to do it async
still implementing db stuff
I think using a ConcurrentHashMap is enough to make it threadsafe
at least in this case
I mean, using a sledgehammer to kill a fly
hey why is the default player inventorytype crafting instead of player, ig its intended but its a bit weirdly described on hub.spigot
But yeah lol
depends on the object being stuffed into that kind of hashmap, but for the most part yes that type of hashmap is threadsafe
There’s performance trade offs to using concurrent hashmap
i'm storing an <uuid, user> where user is a player wrapper
most people really don't have to worry about that though
If you don’t do it async then any time a database call takes any amount of time, which can happen often, your server is going to time out
Good practice is good practice
in this case that doesn't really apply here
what I mean is while there is trade offs with ConcurrentHashMap, most of the time you are going to see performance boosts
not the the other way around unless you are stuffing a crap ton of data into it
IIRC you only need to use the concurrent one if you are modifying it from multiple threads
Reading is fine
yes I was stating earlier above confirming to someone that it was thread safe
No it can’t
If there’s a write associated with your read then it isn’t a read
However
You do have to worry about synchronization when reading from multiple threads if there are writes happening
And in this case there would be writes happening
thats a myth; reading is not always thread safe. If you read and write at the same time, it will cause cme
Reading isn’t always thread safe but reading does not cause a write
concurrenthashmap takes care of that, this is the exact reason it was created in the Java API
ConcurrentHashmap does a hell of a lot more than synchronization, it will do the job here but again, it’s using a sledgehammer to kill a fly
I’m not disputing that it will work
It’s just unnecessary
And there’s also memory overhead to think about if you don’t configure it with an appropriate concurrency level for your use case
why is it highlighted?
anyone know if there's an event for cancelling spectating an entity?
Hover over the highlighted section and see what it says
when i do config.set("Homes", null); it doesn't truly set Homes value to null in config like Homes: {} how can i make it actually set
it just skips
Homes: {} wouldn’t be null, there’s no bracket syntax like that in YAML
I was using that and it lead me to nothing. Through testing, I learned that the only way to check for that is to use PlayerToggleSneakEvent
Which is absolutely sickening to me
but it does work
whats java
Technically I do both but my main focus is Java
I don’t think this is the right channel for that though lol
all these things are not something to be concerned about for most plugins unless they are dealing with a bunch of data
sure, you could think about it and what not, but better to design and getting it working first then to sit there and think about which API method in Java is more optimal to use
Designing it properly from the beginning is the way to avoid something like that becoming an issue later and then being forced to redo a bunch
Just jumping into something without thinking it through is how you make a mess and accumulate a massive amount of technical debt very quickly
there really is no way to design something properly from the beginning not usually
you end up in just a dev cycle if you attempt that
and never release 🙂
There’s a difference between not designing every component before you start and not designing anything before you start lol
This is a simple thing to think about
Hey, is there a work around to getting access(in another class) to this player, in the event
public void DamageEntity(EntityDamageByEntityEvent event) throws IOException {
if(event.getDamager() instanceof Player) {
Player damager = (Player) event.getDamager();
flagCount.get(damager.getName());```
the damager var
I'm referencing getConfig() in an interface that doesn't have a static modifier. It gives me a problem: Non-static field 'config' cannot be referenced from a static contex
That event is going to be called a bunch of times, what are you actually trying to do WRT getting the entity from another class
well we obviously have differing opinions. I am of one that will answer your questions and tell if you something will work and what not, however not really my job to inform and teach nuances of the Java API which is where you seem more concerned with 🙂
You don't become a good developer by not making mistakes
You can make mistakes, or you can get some wisdom from somebody who has already made the mistake and can teach you the lesson directly
The end result is the same
how can i shift a location forwards>
Location#add
i mean on 1 dir
Would need to see the code to give you a specific answer
Add can take a vector direction
so like shift forwards relative to player rot
I'm here again with the same issue trying to get help lol
https://www.spigotmc.org/threads/protocollib-error.539678/
not quite, unless the mistake is going to kill someone or harm someone I agree, however you tend to remember better by being allowed to do something wrong and learning from your own mistake as opposed to someone else's mistake and never understanding why fully the other way is bad in some way
Can we get line numbers?
Context: I'm making a discord bot that runs when the plugin runs
public class Main extends JavaPlugin {
private final YamlConfiguration config = (YamlConfiguration) this.getConfig();
public interface yml {
String BotToken = config.getString("BotToken");
Sorry, how can I do that?
just seeing vector to add
but like I said we obviously have differing opinions which that is ok
Well specifically the line number for the referenced bit of the error would be helpful
and not necessarily need to debate our differences XD
his issue iirc was not having the right fields for BlockBreakAnimation
If you mean this error RPrison.rprison.Rprison.onInteract(Rprison.java:52)
Then it's write(3, location.getBlockZ() + z);
I buy that
?
If it's for me, I've tried a few ways to get to the correct fields, I'm using the fields according to: https://wiki.vg/Protocol#Block_Break_Animation
for this hasmap
if(p.hasPermission("HyperCheat.checkFlags")){
if (args.length == 0){
p.sendMessage(flagCount.get(damage.getPlayername) + " is the amount of flags" + p.getDisplayName() + " has.");```
but instead the shift needed for moving forward
Rotational values can be used in conjunction with a Location to compute a vector direction
If you just want to use the player’s direction there’s methods for that
Is that being called in a command or?
So are you just trying to show them their own flags?
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] HCurrencyAPI-1.0-SNAPSHOT.jar, Hubcore-1.0-SNAPSHOT.jar define 1 overlapping resource:
[WARNING] - plugin.yml
[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/
``` How can I fix this
You don’t need to fix it, see where it says “Usually this is not harmful and you can skip these warnings”
I know that I don't need to fix it. I don't like the warning tho
I’m guessing the error is on that config.getString() call?
@brave sparrow do you know how I can know the correct fields? the main issue is the location..
gradle, on the other hand, flips its sh!t over something like duplicate files
or at least it did for me
Yes
so I need to supply the Player
but then the player is in that Event
as a local variable
The player is the sender of the command
Name of the plugin: should be main class? Which "name"
There’s no double field in the wiki vg section you linked
There’s VarInt, Position and byte
So those are the fields you have to set
wouldnt position be 3 doubles tho?
It would
or maybe 3 ints if its picky
But you can’t just set position to 3 doubles
How can I get to the position? as I saw there are only:
getDoubles();
getFloats();
getIntegers();
getBytes();
didn't see anything to position so I could write on..
I’m not super familiar with the protocol lib methods but according to your error that is the issue
Maybe see what Position is made up of
Is this code inside your main class?
The player is in the command itself as the sender, the event has a variable and the command execution has a variable and they both point to the same thing
The command doesn’t need to reference the event
Yeah I'm trying a few things, thanks 😄
but whats wrong with it
The player your getting the flags of is not the player from that event
/flags another player
to learn more how position is comprised
found this for u msybe @trim crystal https://www.spigotmc.org/threads/protocollib-nms-how-to-use-block-break-animation-packet.442335/
Here's the code
if (sender instanceof Player p){
HashMap<String, Integer> flagCount = damage.getflagCount();
if(p.hasPermission("HyperCheat.checkFlags")){
if (args.length == 0){
p.sendMessage(flagCount.get(damage.getPlayername) + " is the amount of flags" + p.getDisplayName() + " has.");
}else{
Player target = Bukkit.getPlayerExact(args[0]);
if (target instanceof Player){
p.sendMessage(flagCount.toString() + " is the amount of flags" + target.getDisplayName() + " has.");
}
}
}else{
p.sendMessage(ChatColor.RED + "You do not have the required permissions(HyperCheat.checkFlags) to use this command");
}
}```
unlike in game where you are used to xyz, it is in the packet as xzy @trim crystal
If it’s another player then you would use Bukkit#getPlayer with the command argument
Still not the event
26 bits for x and 26 bits for z, y having only 12 bits
How do I use Bukkit#getPlayer to get the player in the event from the other class
((x & 0x3FFFFFF) << 38) | ((z & 0x3FFFFFF) << 12) | (y & 0xFFF)
from wiki.vg they give you an example to encode it properly
You’re linking the command to the event which isn’t what you want
The player in the event is totally irrelevant to the player in the command
Okay let me explain a bit more
Even if it’s the same player
i found the solution, nvm! its inside other class thats why its not working
It’s ok for it to be inside another class, you just have to give it the instance of your main class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Ah I get you!
Hey, thanks alot! it worked for me, been looking for this all day lol
Yeah apparently it's BlockPosition blockPosition = new BlockPosition(new Vector(b.getX(), b.getY(), b.getZ()));
yeah
So I should get the player supplied in the command
Exactly
If you are using protocolLib yes
❤️
np
how protocolLib does stuff isn't the same from the wiki.vg
so you need to refer to their API stuff
ProtocolLib attempts to make it easier instead of messing with stuff like I was showing for example
just wasnt sure what the position field was for protocollib
Nested interfaces in Java are static by default
but that byte field might yell at u since that spigot page showed int
I didn't realize protocolLib was being used here otherwise I wouldn't have bothered referencing wiki.vg stuff XD
his original message showed protocollib code lol
how do i make it non-static
well then that is my bad
yea it was uhh
.
You can’t. Interfaces can’t have member values so they can’t be non static when nested
@fleet imp you’re providing too much implementation for a Java interface
All the interface really includes is method signatures
The implementation comes from implementing classes
how to i convert a string to int or bool
Integer.parseInt(string)
Boolean.parseBoolean(string)
thx
is actions null?
no
Output this.actions to the console to understand that it is not null
is that null?
oh no i save it on disable and load it onenable
Is an exception being thrown in your loadActions()?
If so actions would never be assigned
there isnt any exeption
and actions are being assigned, idk why its giving me a npe when i try to access them
(i store it using json)
Is there any more to the error?
Ok, can we see the whole getFromUUID with line numbers?
yeah
Right before line 55 can you throw in a system print outputting this.actions
can you add a System.out.println("" + actions) before calling the return in getFromUUID
ok
or like an
if (actions == null) System.out.println("uhoh");
shouldn't Javaplugin#saveDefaultConfig() create a Folder with the plugin name and the config file inside?
If you’ve set up config defaults it should
So if the config File is inside the resources folder right?
yes
How did you guys deal with PayPal asking for purchase receipts when you accept payment for good and services? When you didn’t purchase anything
sounds like that wasnt an email from paypal then
I sold a plugin on spigot and they want purchase receipts for verification cause they think I’m reselling or something
PayPal sucks fr
I’m making a chat plug-in we’re it gets the players around a player and sends the message that the player sends only to them. Practically Proximity chat. I’ve tried using the distance method in the players location and the getNearbyEntities Method but they don’t seem to work. It doesn’t give me any errors in console it just doesn’t get the players around that specific player. Any other way I can do this? 😅
Entity#getNearbyEntities
Nah
You probably want to use distanceSquared for something like this
What's wrong with getNearbyEntities
Show what you're doing
"that doesnt seem to work" - what exactly? provide code
Nothing, but when you want a big radius and only players its probably more efficient to loop over all players in that world
Proximity Chat usually isn't that large of a radius
Guess it depends on what you define as a large radius
Like, 50
looping over the players will be more performant
Yeah that's pretty big for prox chat
I’m not at my computer at the moment but I loop through all the entities around that player, I then check if there an instance of a player after I add them to the recipients list. The issue is it doesn’t do the check and just gets everyone anyways...
And I clear the recipients list before
so you are doing smth wrong
We can’t really so much without the code
Ok then I’ll do that in a bit 😅
how do i send text to chat with a plugin
To one player? All players?
all
Bukkit.broadcastMessage
anyone know why actions would be null even when im loading it?
If logfileroot already exists you don’t load anything
^
omg thank you so much i hope this works
Anyone know how to force a plugin to use a dependency packed with it instead of the version packaged with the server? (Gson version used is about 5 years out of date; trying to use the latest version, but it seems to be sticking with the server provided copy...)
Shade and relocate it and it should be used
Yeah if you shade it it will use internal dependencies.
Relocate is the important part
Gotcha, I'll look into it. Thanks!
Im using a PlayerMoveEvent for a trampoline thing im making. I want to make a block then when stepped on, breaks. I currently do this with metadata as such java if (!isUsed(belowLoc.getBlock())) { event.getPlayer().sendMessage("hasnt been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setMetadata("UsedOnce", new org.bukkit.metadata.FixedMetadataValue(Trampotdi.getInstance(), true)); } else { event.getPlayer().sendMessage("has been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setType(Material.AIR); }
In chat I see both hasnt been used and has been used
the block instantly deletes, any idea how to fix?
the isUsed function if youre curious public boolean isUsed(Block b) { List<MetadataValue> metaDataValues = b.getMetadata("UsedOnce"); for (MetadataValue value : metaDataValues) { return value.asBoolean(); } return false; }
The event gets called a lot
Make sure the event isn't triggered twice or more by adding a cooldown for exemple. With your code, the PlayerMoveEventwill be triggered multiple times
(When the player velocity is updated, the player move again, triggering the event, that make the player move again, etc.)
So it’s getting called twice when the player steps on it
Yeah, im seeing that I put the from and to methods location's to strings. I guess a cooldown is nessasry