if (e.getEntity() instanceof Arrow) {
Arrow arrow = (Arrow) e.getEntity();
Entity shooter = (Entity) arrow.getShooter();
Location loc = getLocation(e);
if (arrow.hasCustomEffect(PotionEffectType.CONDUIT_POWER)) {
int size = 10;
loc.getWorld().createExplosion(loc, size, setFire, destroysBlocks, shooter);
} else {
if (arrow.hasCustomEffect(PotionEffectType.DOLPHINS_GRACE)) {
((Entity) arrow.getShooter()).teleport(loc);
}else{
if(arrow.hasCustomEffect(PotionEffectType.WATER_BREATHING)){
loc.getWorld().strikeLightning(loc);
}else{
if(arrow.hasCustomEffect(PotionEffectType.FAST_DIGGING)){
loc.setPitch((float) 0.0);
loc.setYaw(90 - loc.getYaw());
Vector dir = loc.getDirection();
Location wallLoc;
for (int height = 0; height < 2; height++) {
for (int width = -1; width <= 1; width++) {
wallLoc = loc.clone();
wallLoc.add(0, height, 0);
wallLoc.add(dir.clone().multiply(width));
wallLoc.getBlock().setType(Material.STONE, false);
}
}
}
}
}
}
return true;
}
return false;
}```
#help-development
1 messages · Page 1346 of 1
?paste
i just tested it it allways faces north
Then your location method you are using is wrong
get the entities location. The code I gave you definitely works
so ive tried that and it sort of works
it doesnt do exactly what you said it would
but now i dont have to modify it to do a 221
and the wall is diagonal
it does exactly what I said it does. The wall will be 90 degrees to the player and 2x3
oh for me it ends up at 135
it all depends on which way you are facing. it will always be 90 degrees to the player
Take it slow. Create methods that run the operations line by line. You would need a stream for doing it like this
thanks
Are you sure that the API exists at runtime and that the method exists there at runtime?
When do you use return true or return false when it comes to commands?
If you return false, spigot will display the command syntax
Maybe update the API ¯_(ツ)_/¯
You might have an outdated API jar
But you are still linking to the newest version
How do I run a command every minute? Should I use a Bukkit runnable or is there a better way
What's the command every minute to do?
Is it vital that it's exactly 60 seconds and is representative of real world time? If so use a scheduled service executor, otherwise use the bukkit scheduler.
Yes, every 60 seconds in real world time I need to change a block drop
Thank you
maybe check whether the method really exist with a bytecode editor or something similar
Although, it is basically a given that the method does not exist
If Java tells that it didn't find a method, that's because it wasn't there in the first place
My guess he might be using plugman or just build it wrongly
accessing another plugins API before the server is fully started is not a good idea.
did you depends it?
run yoru setWelcome 1 tick after your onEnable has finished
Hi,
I was wondering if someone could help me figure out how to save my hashmap in onDisable and read it in onEnable. My hashmaps are:
public static HashMap<Player, BossBar> bossbar = new HashMap<Player, BossBar>();
Until now, I have found ```
for (Entry<String, String> set : money.entrySet()) {
getConfig().set("money." + set.getKey(), set.getValue());
}
saveConfig();
for (String users : getConfig().getConfigurationSection("money").getKeys(false)) {
money.put(users, getConfig().getString("money." + users));
}
You can;t read/create player objects in onEnable, unless its a reload
Meaning?
when the server is starting there are no player objects at all
I want to like save it in config file
Or something like that
But I have no idea how to
save the players UUID not the player object
ok
you shouldn't even be saving Player either cause if the player disconnects the instance becomes invalid
^
Then how am I supposed to save the player's mana?
UUID
Well WeakHashMap can solve it otherwise
Meaning?
Don't use WeakHashMaps if you do not know what they do
But it’s not liable really
Or better said, if you don't know how java's GC works
just don't store player objects at all. reference UUID and whatever data you need
I don't know how to read that though
I mean if another plugin holds a player object then it won’t be cleared in that weakhashmap subsequently
Bukkit.getPlayer(uuid)
or getOfflinePlayer as that is persistant
UUID.fromString(string)
so something like ```
List<String> hashmapData = new ArrayList<String>();
for(UUID uuid: kills.getKeys()) {
String data = uuid.toString() + ":" + kills.get(uuid);
hashmapData.add(data);
}
getConfig().set("your.path.here", hashmapData");
saveConfig();
String[] raw = rawData.split(":");
kills.put(UUID.fromString(raw[0]), Integer.valueOf(raw[1]));
}
Are you sure you set up the loadbefore properly
what is SMPAdmin's plugin.yml?
then your test API is failing to load
also, don;t use softdepend if you need it. only depend will control load order
.
depend does control load order
Oh it doesn’t?
Though it is encouraged to use softdepend instead of depend when it is not a hard depend, even if it does not control load order
Or better said, mandatory
I went through all the CB loading code a while back to resolve a load order issue. depend does control load order. soft doesn't
Hmm interesting
source?
depend makes it a harddepend = plugin won't load if the dependency is not found
That’s good though
Unless that has been changed (or I am misremembering things)
if you're making an API, you shouldn't be explicitly defining any loadbefores as you can't possibly predict what will depend on it
?paste your full plugin.yml
Hello, I can not send packets from spigot, after looking at the forums :
((CraftPlayer) player).getHandle().playerConnection.sendPacket(Packet<?> packet);
I found this trick but it does not work, it tells me that the class is not found, I am in 1.16
do you have nms as a dependency set up correctly?
I don't have this dependance, can tou stand me the link for the librairie ?
are you using maven or gradle
remove the loadbefore
gradle
nms isn't hosted online anywhere, so you will have to run buildtools at least once to add it to your local repo
and test
the dependency itself will be the same as spigot-api, except remove -api
and of course make sure to include mavenLocal()
CB loading is weird, softdepend and one other messes up load orders. I only ever found depend to actually control the load order.
can you send me the link to the bookstore?
The what
assuming you meant library, it's not hosted online as it means hosting mojangs code, which is illegal
.
I like bookstore better honestly
How can I opt for it then?
.
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
but that is not for spigot plugin ?
Also known at the .m2 folder
You can return consumers
im also interested bout this in java lol in c++ u just use function pointer
Is a there a playername parameter in Material.HEAD itemstack or something?
SkullMeta
ty
You can just return the result of getConfig?
How is this for saving my hashmap?
always check teh javadocs
Now that I've done this how do I do
Change the dependency to spigot instead of spigot-api
And make sure you have mavenLocal as a repo
In java you use either reflection (for the reflection method) or functional interfaces (like callable, consumer, biconsumer, supplier, bisupplier, etc.)
can someone explain to me why this generator does not work how i expect it to? https://pastebin.com/ry7WUGhK
Pastebin
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.
(i.e. there are sections of void which get progressively larger the farther you get)
I've seen this one once
I think I messed something up with X and Y or something like that, cannot really recall what I did then
how do i add potion effects to players?
https://paste.md-5.net/usafuzuzas.coffeescript I currently have this code and it does work
why would it only last 1/2 a secccond?
I might be misunderstanding the way chunkdata works. Is it relative?
ohhhhhhhhhhh cus of ticks tright?
10 ticks is 1/2 a second
tysm
that might be possible, I'd guess just https://tryitands.ee
well I'm currently afk so I'll do it later
I think it being relative would make a lot of sense
for how it generated
The plugin is null
explain ur situation more .-.
how do I check the display name of a clicked item in a gui?
event.getCurrentItem.getItemMeta.getDisplayName
thanks
Be aware a lot of that is nullable
Are you calling the static methods before you call the constructor
location.getBlock().setType(Material.AIR)
Thank you, it work
Hi, I am trying to disable renaming of 2 items. The code is:
@EventHandler
public void inventoryClickEvent(InventoryClickEvent event) {
if (!(event.getInventory() instanceof AnvilInventory)) {
return;
}
if (event.getSlotType() != InventoryType.SlotType.RESULT) {
return;
}
if (event.getCurrentItem().getItemMeta().equals(ItemManager.sword.getItemMeta()) || event.getCurrentItem().getItemMeta().equals(ItemManager.wand.getItemMeta()) ) {
event.setCancelled(true);
}
}
It doesn't work though
Ok changed code
public void inventoryClickEvent(InventoryClickEvent event) {
if (event.getInventory().getType() == InventoryType.ANVIL) {
if(event.getSlotType() == InventoryType.SlotType.RESULT) {
event.setCancelled(true);
}
}
}
this is code
but this disables anvils completely
which i dont want
how do i fix that?
sysout the event.getSlotType().name()
How can I set the position of itemstack inside the inventory?
In an inventory? setItem(slot, stack)
How should I make my item rightclickevent work even when the item is renamed?
thx ive been using it differently
try getting the item name
But that won't help
dont do that!
specific item
Like i have a custom item
with a ability
NBT tags
Persistentdatacontainer
Use PDC
tried that but i couldnt figure it out
PDC
i will try this
NBT is 2000% more complicated than PDC
but i dont understance concept of that
U must be over 1.14
NBT is a wrapper around PDC as far as I know thanks to bukkit patches
Other way
But u can do so many things with it.
PDC wraps NBT
No, the other way around
And you can do almost everything you can with NBT using PDC
NBT is the root, PDC is the wrapper API
Just use one of them, the one u like the most
I don't understand either
You have Javadocs and a tutorial
I am a bit new to the convo, so what exactly do you want to store?
Does comparing item metas compare itom names?
Just wait till you see Sponge's data API
Basically i have a sword with a right click ability
and i want ability to work even when item renamed
yes
Ah, so first get the PDC which is the itemMeta
Yep, Store a type flag in the PDC.
ok
Then store a Byte in the PDC, which will act as a flag, you can then remove it if you want to remove the action
so itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, Math.PI); line basically ?
Yes, somewhat like that
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
ItemMeta itemMeta = itemStack.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if(container.has(key , PersistentDataType.DOUBLE)) {
double foundValue = container.get(key, PersistentDataType.DOUBLE);
}
this is code to access
right?
ok
not a good idea if you want to do somethign only if the flag exists
Always depends on the usecase I would say
yep
PDC is great for APIs
My plugin supports adding a thirst replenishment value to any item with PDC
Is there a way to add custom nbt data to an armor stand? I've already tried NMS, but couldn't get it working for entities. Is this possible without the use of external API's?
PDC
so, would it be something like armorStand.getPersistentDataContainer().set(...)?
yes
thanks!
I'm basically trying to make a /heal and /heal <player> command..
When I have perms for heal.heal I can heal myself and heal other players
and When I have perms for heal.heal.others I can't heal myself or other players.. I want to do it so If I do /heal it heals the one who did it, and If I do /heal <player> It heals arg1
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("heal")) {
if (player.hasPermission("heal.heal")) {
} else {
player.sendMessage(ChatColor.RED + "Sorry, you do not have permission to use that command.");
return false;
}
if (args.length == 0) {
player.setHealth(20);
player.sendMessage(ChatColor.YELLOW + "You've just healed yourself.");
return false;
} else if (player.hasPermission("heal.heal.others")) {
} else {
player.sendMessage("You don't have permission");
}
if (args.length == 1) {
if (player.getServer().getPlayer(args[0]) != null) {
Player targetPlayer = player.getServer().getPlayer(args[0]);
targetPlayer.setHealth(20);
player.sendMessage(ChatColor.YELLOW + "You've just healed a player.");
targetPlayer.sendMessage(ChatColor.YELLOW + "You've been healed.");
} else {
player.sendMessage("This player is not actually online.");
}
}
}
return false;}
}
?paste
What
you have no return statement for the second permission check btw
You mean for if (args.length == 1) { if (player.getServer().getPlayer(args[0]) != null) { Player targetPlayer = player.getServer().getPlayer(args[0]); targetPlayer.setHealth(20); player.sendMessage(ChatColor.YELLOW + "You've just healed a player."); targetPlayer.sendMessage(ChatColor.YELLOW + "You've been healed."); } else { player.sendMessage("This player is not actually online."); ?
oh
Where should I put the return statement?
under "player.sendMessage("You don't have permission"); ?
I'm new to java tho
you need a good working knowledge of java to effectively write plugins
Then Jochyuas statement makes sense
my statements never make sense
🎈

does your textformatter take basecomponent
rats
public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("heal")) {
if (player.hasPermission("heal.heal")) {
} else {
player.sendMessage(ChatColor.RED + "Sorry, you do not have permission to use that command.");
return false;
}
if (args.length == 0) {
player.setHealth(20);
player.sendMessage(ChatColor.YELLOW + "You've just healed yourself.");
return false;
} else if (player.hasPermission("heal.heal.others")) {
} else {
player.sendMessage("You don't have permission");
return false;
}
if (args.length == 1) {
if (player.getServer().getPlayer(args[0]) != null) {
Player targetPlayer = player.getServer().getPlayer(args[0]);
targetPlayer.setHealth(20);
player.sendMessage(ChatColor.YELLOW + "You've just healed a player.");
targetPlayer.sendMessage(ChatColor.YELLOW + "You've been healed.");
} else {
player.sendMessage("This player is not actually online.");
}
}
}
return false;}
}
This is the code
so if you don't have the heal.heal permission, you get returned
you need heal.heal and heal.heal.others
@SuppressWarnings("deprecation")
Is it possible to do If I had no heal.heal but only heal.heal.others so I can heal only other players?
so how?
have you used switch statements before?
Wdym
can you stop ping me please
its ok
This beginner Java tutorial describes fundamentals of programming in the Java programming language
I'm not pinging
yes, I know
Its autoremoving it
it is pesto
Yes apologies
@dusty herald 💩

???
so how do I do it tho
Conclure bully
What black magic is this
I'd suggest reading the link he sent
so if I were to do something like that with permissions, I'd probably do this
switch(player.getPermission()){
case "heal.heal":
break;
case "heal.heal.others":
break;
default:
player.sendMessage("You don't have permission");
break;
}```
not because I love switch statements tho
So I'm trying to make a custom book and i've been looking around at some code for a while trying to figure out how to do it. The code gives me this error that I haven't seen happen to anyone here is my code.
Can you edit my code and do it how I want?
open a book server side?
or should I add the code you sent?
I can't paste an image
verify
ok
Does someone know how minecraft generates BIOMES?
that's very vague
agreed.
procgen is an artform in itself
what
procedural generation
huh
I suggest you do it
Where should I place it?
hm
using a seed
also why did you capitalize that
I know that it uses a seed...
doesnt it just use the seed for an rng
replace all of your permission checks with it, but only put it once
no
it uses the seed to generate noise
idk how that happens
ah ok
Bruh..
bruh what
I'm not lazy but
noise is random but ok
I don't understand where should I put it
well biomes also use the seed... a lil bit
not from a seed it isn't
it is?
you always get the same noise from a seed
alright.. going back to the question...
whatever it is, it's bloody complicated
that is tru
I am trying to make a written book but i get an error that says "enum types may not be instantiated" Here is my code
Any ideas?
exception?
lots of different ones
there is no equation
it's not an equation
it's an enum, it's already instantiated
your best bet is gamepedia and https://wiki.vg/ @vestal dome
or looking through obfuscated source
or deobfuscating that source
best bet is decompiling NMS
Hi, I was wondering if someone could help me stop renaming items in an anvil but keeping the ability to apply enchantment books. I have some code right now:
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent e){
if(!e.isCancelled()){
HumanEntity ent = e.getWhoClicked();
if(ent instanceof Player){
Player player = (Player)ent;
Inventory inv = e.getInventory();
if(inv instanceof AnvilInventory){
InventoryView view = e.getView();
int rawSlot = e.getRawSlot();
if(rawSlot == view.convertSlot(rawSlot)){
if(rawSlot == 2){
ItemStack item = e.getCurrentItem();
if(item != null){
ItemMeta meta = item.getItemMeta();
if(meta != null){
if(meta.hasDisplayName()){
String displayName = meta.getDisplayName();
e.setCancelled(true);
}
}
}
}
}
}
}
}
}
which I got from: https://bukkit.org/threads/inventory-anvil-events.142990/
However, this stops using anvils altogether, not just renaming. I was wondering if someone could help me solve this problem.
Hello,
I do not know whether this already exists or if it is implemented in the latest builds, at least not in mine.
For my plugin I needed a way to...
and killing myself for 10 minutes to figure it out
code blocks reeeeeeeeeeee
why stop renaming?
aka the source code
Can you tell me how I would format that line?
am I right?
should we go to #text
got this feeling you should be using PDC's instead of stopping renaming
sure
As if the custom items were renamed, their ability stops working
but that is like hair tearing stuff, you have to figure out what each class does
how?
also iirc, spigot deobfuscates class names
the maps are public
you should be using PDC's in that case instead of stopping renaming
what does that have to do with anything
it's much easier than doing it obfuscated
deobf maps
i tried
but i couldnt figure it out
o
so here i am
well you should definitely try pdc's, its better in the long term
mcf has deobfuscation maps for every release since 1.14 ish
mcf?
minecraftforum
try again
but could not figure it out
i tried for around 5 hours
then you need to spend more time learning
Life's hard.
ooooo nice one
what
hmm?
?mmh
kik
you know that feeling when you start looking through your code and realising its shite and then begin having a breakdown
:)
every day
relatable
cute
᠄
imagine spelling it centre instead of center
a
and colour insteaed of color
just starred it lucy :]
why not lmao
lmfao
i need to redo it with components at some point
i forgot to commit a file
any idea how to edit just the text of a component 
lol
rn I'm editing just the json and it's being a bitch to me
yeah im not exactly smart
ja son
ja son
ja son derulo~~~~

just shoot me
Can someone give me feedback on https://www.spigotmc.org/threads/mana-system.497803/#post-4124530 apart from static abuse
@lost matrix
I have getCommand("ag").setExecutor(new Commands()); in my onenable, but how do i add a permission to this
Looking at the hashmaps i can already see an issue
It stores player object
Yep
found that is an issue
hey is there any way for me to make it so a player can use riptide during non-rainy weather? Spigot api doesn't seem to offer this
and fixing it
Yeah, also you're using the ManaSystem as an object, but only accessing static methods?
Why
Why bother with anything static then?
return this.isInWater() || this.isInRain();
}
public boolean isInWater() {
return this.inWater;
}
private boolean isInRain() {
BlockPosition blockposition = this.getChunkCoordinates();
return this.world.isRainingAt(blockposition) || this.world.isRainingAt(new BlockPosition((double)blockposition.getX(), this.getBoundingBox().maxY, (double)blockposition.getZ()));
}
welp
Player player = .... // your player
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.inWater = true;
online
search
idk
or ```
Map<UUID, World> fakeRainWorld = new HashMap<>();
@EventHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) return; //prevent double firing
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
if (event.getItem() == null) return;
ItemStack item = event.getItem();
if (item.getType() != Material.TRIDENT) return;
if (item.getEnchantmentLevel(Enchantment.RIPTIDE) <= 0) return;
Player p = event.getPlayer();
World world = event.getPlayer().getWorld();
if (world.hasStorm()) return;
world.setStorm(true);
fakeRainWorld.put(p.getUniqueId(), world);
for (Player player : world.getPlayers()) {
player.setPlayerWeather(WeatherType.CLEAR);
}
}
// reset real weather again if player riptided
@EventHandler
public void onTrident(PlayerRiptideEvent event){
fakeRainWorld.remove(event.getPlayer().getUniqueId());
World world = event.getPlayer().getWorld();
// no reason to keep fake rain if no-one is trying to riptide anymore
if (!fakeRainWorld.containsValue(world)){
world.setStorm(false);
for (Player player : world.getPlayers()) {
player.resetPlayerWeather();
}
}
so in playerinteractevent
if rightclick
and player is holding trident
player.getInventory().getItemInMainHand().getEnchantments()
check if riptide
Im probably too biased regarding code structure and design patterns so i would probably just scrap and re-write it. But ill give you the low hanging fruits.
For one: Single character variable names are pretty much a no-go unless they are used int 2 or 3 consecutive lines.
Next: max mana is a hard coded constant
Then: Hard referencing a Player object is a bad idea in most cases. Use the UUID instead.
Finally (and most important):
Your code doesnt work.
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
for (Player p : Bukkit.getOnlinePlayers()) {
if (!(hasMaxMana(p))) {
continue;
}
if (getPlayerMana(p) < MAX_ArcanePower){
addMana(p, 1);
}
bossbar.get(p).setTitle("Arcane Power: " + getPlayerMana(p));
bossbar.get(p).setProgress(getPlayerMana(p)/ MAX_ArcanePower);
bossbar.get(p).setVisible(true);
bossbar.get(p).addPlayer(p);
}
}
}, 0L, 20L);
This will just skip every player unless he has max mana. And in that case no mana is added.
oh right yh
forgot to remove exclamation mark
wait it does work
im dumb
that why work when not supposed to
public static boolean hasMaxMana(Player p){
if (getPlayerMana(p) < (MAX_ArcanePower +1)){
return true;
}
return true;
}
this tells if player not got maxmana
not if got maxmana
im dumb
gonna update it
I need help, My tablist header and footer do not want to go, there is no error in the console, I don't know what to do; (
https://paste.gg/p/anonymous/f608297093d84a3a8521dff368dfdf8c
by doing player.setPlayerWeather(WeatherType.DOWNFALL), i'm able to make the player riptide in place
does Minecraft require water particles in the air for the Riptiding trident to actually go forward?
System.out.println("§8§m--------------------------------------------------------");
System.out.println("§7§m");
System.out.println("§8§l >> §d§lWurmiTabList v1.0 §8§l<<");
System.out.println("§7§m");
System.out.println("§d WurmiSystem was successful activated!");
System.out.println("§d Created by CUTE CAT");
System.out.println("§7§m");
System.out.println("§8§m-------------------------------------------------------");
}```
please dont do this
Use 1.16. There you can just send the header and footer via the API.
and if you're going to do it, please at least use the right method
no
It has to actually rain on the server for that. The server prevents leaping because the use is just not allowed to do that without it actually raining on the server.
if standing in water then again works
is there a way to stop a spawned item from being pushed out of a block
SO I am trying to get the normal overworld world to be passed in as a World object becuase my code doesn't use a player but does require a world for a Location object any easy way to do this?
Bukkit#getWorld(String)
or getWorlds()
the latter will have the first entry being your overworld.
why ^^ 🙂
and how work it in 1.8.8?
You need packets in 1.8 iirc
much appreciated I was going to try a work around but now I don't have too thanks
Not going to bothered looking that up for an ancient version
fills the console with things that aren't important, distracts from the actual important messages
especially with colours
... 😭
all you really need is the default enable message imo
but i want to see that the plugin is activated 🙂
okay... ;/
theres a message built in for that
literally says in console any plugins that are enabled or disabled
without custom messages
Hi, I was wondering if it was possible to add armor/toughtness to a skull or an other item ?
yes, see itemmeta and attribute modifiers
Ok, thanks ^^
I love 5+ lines in console for every plugin ever
really brings out the artistic side of console
I'll add some extra girth
Looks nice lmao
is this not the right way to spawn a custom colored redstone dust particle?
It says it Needs data, but null was provided
toSpawnOn.spawnParticle(Particle.REDSTONE, toSpawnOn.getLocation(), 1, colorArray[0], colorArray[1], colorArray[2], 1);
I need help, My tablist header and footer do not want to go, there is no error in the console, I don't know what to do; (
https://paste.gg/p/anonymous/f608297093d84a3a8521dff368dfdf8c
is it bad idea to extand Player interface to my BTPlayer inerface ?
should i just make Player fieald in my class and assignee player to it ?
The later
Now I used this and its the same error:
toSpawnOn.spawnParticle(Particle.REDSTONE, pLoc.getX(), pLoc.getY(), pLoc.getZ(), 0, colorArray[0], colorArray[1], colorArray[2], 1);
Caused by: java.lang.IllegalArgumentException: Particle REDSTONE requires data, null provided
Use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html#getDataType() on the particle
So this (1):
toSpawnOn.spawnParticle(Particle.REDSTONE.getDataType(), pLoc.getX(), pLoc.getY(), pLoc.getZ(), 0, colorArray[0], colorArray[1], colorArray[2], 1);
Or this (2):
toSpawnOn.spawnParticle(Particle.REDSTONE, pLoc.getX(), pLoc.getY(), pLoc.getZ(), 0, colorArray[0], colorArray[1], colorArray[2], 1, Particle.REDSTONE.getDataType());
ah
How can I store the information about a banner in a config file? This code doesn't seem to work for me:
public BannerMeta getBanner(String clan) {
ConfigurationSection cs = clanData.getConfigurationSection("clan." + clan + ".banner");
return (BannerMeta) ConfigurationSerialization.deserializeObject(cs.getValues(false));
}
public void setBanner(String clan, BannerMeta meta) {
clanData.set("clan." + clan + ".banner", meta.serialize());
saveClanData();
}
It gives me:
[16:36:46 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'setbanner' in plugin
...
Caused by: java.lang.IllegalArgumentException: Args doesn't contain type key ('==')
at org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(ConfigurationSerialization.java:204)
This is what gets stored in the config:
banner:
meta-type: BANNER
patterns:
- ==: Pattern
color: BLACK
pattern: cs
- ==: Pattern
color: WHITE
pattern: cs
- ==: Pattern
color: BLACK
pattern: sc
- ==: Pattern
color: WHITE
pattern: mc
- ==: Pattern
color: WHITE
pattern: mc
- ==: Pattern
color: WHITE
pattern: mc
The method deserializeObject(Map<String,?>) in the type ConfigurationSerialization is not applicable for the arguments (ConfigurationSection)
Should I just do a typecast?
Caused by: java.lang.ClassCastException: class org.bukkit.configuration.MemorySection cannot be cast to class java.util.Map (org.bukkit.configuration.MemorySection is in unnamed module of loader 'app'; java.util.Map is in module java.base of loader 'bootstrap')
return (BannerMeta) ConfigurationSerialization.deserializeObject((Map<String, Object>) cs);
My plugin has clans, and each clan can set their flag. If the clan is the top clan then their flag replaces all banners at spawn
To do that it looked to me like the best way is just save the banner meta
Doesn't seem to want to load properly though, and the only method of a ConfigurationSection that returns a Map<String, Object> is getValues()
hmm
hello, how can I get InputStreamer and get it as a FileConfiguration?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/configuration/serialization/ConfigurationSerializable.html
It doesn't look like BannerMeta has a constructor or a valueOf() or deserialize() method.
Can't find them, when I try to use them eclipse says they don't exist
public void onHunger(FoodLevelChangeEvent e) {
e.getEntity().getWorld().getName().equalsIgnoreCase("ffa");
e.setCancelled(true);
}
}```
The world I'm in is not "ffa" and it still cancels the event of foodlevelchange... Anyone help me please
Wait
if (e.getEntity().getLocation().getWorld().toString().equalsIgnoreCase("ffa")) { This one?
do you mean this?
yes
public void onHunger(FoodLevelChangeEvent e) {
if(e.getEntity().getWorld().getName().equalsIgnoreCase("ffa"))
e.setCancelled(true);
}
}```
This works?
try it out
where would you need ;
I won't need it I guess
I meant in ``` if(e.getEntity().getWorld().getName().equalsIgnoreCase("ffa"))
ah
the semicolon is just saying stop here, go to the next line
Thanks for telling me that too
no worries
I will try to put my world name now
I hope it works
and no hunger
It works!!
Thanks a lot. I appreciate that.
😄
Does this mean I can't deserialize using just the spigot API?
when in doubt, base64 it lel
You can, I was just showing you it exists
I don't have anything under org.bukkit.craftbukkit
spigot-api-1.16.5-R0.1-SNAPSHOT.jar
arent you using maven
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
you need to depend on craftbukkit for nms
More specifically you need to depend on spigot
Which requires you to build the source locally with buildtools
So if I wanted to put this into maven I'd use my local repo/cache thing?
mavenLocal()
Yeah
/home/<user>/.m2/repository
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
mvn install:install-file -DgroupId=com.stackoverflow... -DartifactId=yourartifactid... -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/jarfile
you can use NMS with these dependencys.
You only need the 1
guys is there a way to fix this error in buildtools?
org.eclipse.jgit.api.errors.JGitInternalException: Could not rename file CraftBukkit._LGPL.txt2874828113175665030.tmp to CraftBukkit\LGPL.txt
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
you need this one for NMS so idk what you mean?
Changing everything to CraftMetaBanner didn't fix anything
Even BannerMeta had serialize, what I was looking for was deserialize, valueOf or a constructor accepting Map<String, Object>
I found the constructor in CraftMetaBanner but it's not public (I can't access it)
wtf are you doing
lol
just call .set / get and cast appropriately
dont touch deserialize / serialize manually
Literally config.set("foo", banner); BannerMeta banner = (BannerMeta) config.get("foo")
https://pastebin.com/0cXBVLgM
it doesnt print "hi" whenever I hit someone with an axe and i have the spider eye enchant
idk why
yessir
Add some debug prints to figure out where it stops
is it possible to use a placeholderapi placeholder without a player?
PaceholderAPI#setPlaceholders(Player, String);
I want to get rid of the Player, since there's no Player field in my method
@south onyx obviously the problem is going to be line 22
is the condition returning what you expect it to?
have no idea what your main looks like, and also recommend changing the name of your main class from main to something else
not required, but its good etiquette
i don't think clip has made that possible
looking into the methods, you require either player or offlineplayer
i think it's cause to register a new placeholder with the expansion this is the method public String onRequest(OfflinePlayer player, String identifier) { so it requires a offlineplayer
oh
Well I want to use bungee placeholders inside a runnable which is inside a void thats being called from onEnable
I guess I'll have to make a separate method just to get the placeholder
Player extends OfflinePlayer...
you can pass in a player to something that requires an OfflinePlayer
not what i was saying but ok
pass in a random offline player and just return the same thing no matter the player
Ok so I am trying to code a plugin but I don't want to use / as the command prefix I want to use @ but whenever I type a command from my plugin into chat It prints out what command I ran into global chat, how can I make it so it doesn't output any message
event.setCancelled(true);
if you dont mind im gonna spoonfeed a class since i feel like it
might add it to galaxylib
nvm ill just code it later
Like when someone types @help it doesn't print to global chat
like /help
but @help
use the AsyncPlayerChatEvent
event.setCancelled(true);
Ok 👍
also thats a horrible idea
Oh
no tab complete
i wouldnt play your server if the commands didnt have tab complete
It's complicated
k no worries
Does anyone know what code i would need to find a book in a players inventory and then take the page data out of said book?
all documentation i can find is old
Maybe set the health of it to half of max health
I ahve question
if you're making a plugin in kotlin, can't you just make the main class an object
How do I set the base colour of an already-placed banner? Here's what I have so far:
Block bannBlock = ((Player) sender).getWorld().getBlockAt(-88, 72, -194);
CraftBanner banner = new CraftBanner(bannBlock);
BannerMeta meta = getBanner("clan2");
banner.setBaseColor(DyeColor.RED);
banner.setPatterns(meta.getPatterns());
banner.update(true);
The patterns are applied to the banner but the base colour of the banner is not changed from its original.
What is the best pratices for creating and accessing mysql databases on servers?
Generally you want to do it async
I tried both banner and craftbanner and they both don't work. It works with Banner.setType()
I mean methods and stuff, should I just use java.sql? what's the best way to create db?
Come to think of it the individual colours were separated in the flattening weren’t they
The problem now is if I use Banner.setType() the rest of the metadata (or whatever it is in 1.16) is removed
So the rotation of the banner is broken
You can probably copy the rest of the data from the blockstate
Or blockdata, forget which it is
boolean isAttached = ((Attachable)bd).isAttached();
BlockFace facing = ((Directional)bd).getFacing();
banner.setType(clans.getBannerType(clan));
((Attachable)bd).setAttached(isAttached);
((Directional)bd).setFacing(facing);
I guess this is OK
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.
?ask
ask then we may be able to help
packet listeners aren't working for me
show some code
just the example on the wiki
https://paste.md-5.net/uxuhufekek.cs
Hi, how could I get the base attributes from a vanilla item ? (So the basic generic.attack attribute from a sword for example)
why do you have an if(true) statement
you can do alot of that stuff with ItemMeta 🙂
laziness
Is this your code?
that is the wiki example thing
Could you link the Wiki?
inside my onenable
have you debugged whether it is even firing
Actually I tried by doing ItemMeta#getAttributeModifiers() but it returns null for a non modified item
it logs when it fires I think
oh, i see, yeah that would makes sense if it has no modifiers
so it fires, it just doesn't cancel?
The thing is that I would like to get the original attributes
for a modified item or?
no, it doesn't even fire
A non modified one
I would think the default getValue would be the vanilla attributes
But it could be some weird hard coding
no error msg?
no
also
why two managers
manager = this.getServer().getPluginManager();
manager.registerEvents(this, (Plugin)this);
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
should definitely change the name on one of them
Like doing Attribute#getValue() ?
That wouldn't work as the values varies from items
The thing I would achieve is to get the property of an armor for example and transfer them to a non armor item like a feather
still isn't working ¯_(ツ)_/¯
However if it returns null for getAttribute that’s an issue
yeah it does returns null :/
ItemStack#getDurability will get nms #getDamage if that's what you're looking for (i think) .. i also think that other stuff might be in nbt so you might be able to get it through that? not 100% sure though it's been a sec
I'm not looking for the durability
But for the Armor and thougness for example
or event the damage of a sword
Yeah it’s probably accessible in NBT, but that would be NMS
thoses kind of things
yeah that would be #getDurabiltiy() to get the sword damage
no?
Not durability
Yeah attack damage ^^
no clue then, could be a bad dependency or something
You could make a lookup table to avoid NMS I suppose
make sure you're running the correct version
Mmmh maybe with an nms copy of the item I can get all the actual attributes
terminology is dead
Yeah, over there the damage are the damage the item got from it's usage
Not the damages it deals
hmm
Yeah it appears those values aren’t accessibly with the attribute API
So lookup table or NMS
ok ok thanks for the help
BannerMeta meta = clans.getBanner(clan);
BlockData bd = Main.plugin.getServer().createBlockData(banner.getBlockData().getAsString().replaceAll(":[a-z]*_", ":red_"));
banner.setBlockData(bd);
banner.setPatterns(meta.getPatterns());
banner.update(true);
Is there any better way to set the base colour of a banner than this abomination? I tried using Banner.setBaseColor() and it didn't work because it's in BlockData now, and I tried using Banner.setType() to set it to another banner material but that destroyed all the other block data like rotation and whether it's attached.
I tried this but it didn't work (the type casts were invalid):
boolean isAttached = ((Attachable)bd).isAttached();
BlockFace facing = ((Directional)bd).getFacing();
banner.setType(clans.getBannerType(clan));
((Attachable)bd).setAttached(isAttached);
((Directional)bd).setFacing(facing);
With shitty regex?
String colour = clans.getBannerType(clan).toString().replaceFirst("_.*$", "").toLowerCase();
BlockData bd = plugin.getServer().createBlockData(banner.getBlockData().getAsString().replaceAll(":[a-z]*_", ":" + colour + "_"));
:(
I'm trying to usePlayer.launchProjectile() and the docs say I should use something which extends projectile. I'm trying to get it to have the player launch an arrow, so what's the best way to do that? I can't create an instance of Arrow (duh) so what should I do?
you can definitely spawn arrow's
Yeah but what should I pass in launchProjectile?
an implementation of arrow?
Arrow is a projectile last I recalled
hold on one sec
how do I get the data out of a packet from a packet listener
Ok arrow is an interface
Sure, and you can cast it to Projectile as well
but I'm confused
how am I supposed to create an instance of arrow
It's abstract
There is AbstractArrow and there is Arrow
so literally Player.launchProjectile(Arrow.class);
Mhm
you can if you really wanted to. IE want custom projectile objects etc
no thanks
Got it 😄
public static ItemMeta computePreexistingAttributes(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
if(meta == null) return null;
for(EquipmentSlot slot:EquipmentSlot.values()){
Multimap<AttributeBase, net.minecraft.server.v1_16_R3.AttributeModifier> multimap = CraftItemStack.asNMSCopy(item).a(CraftEquipmentSlot.getNMS(slot));
for(Entry<AttributeBase, Collection<net.minecraft.server.v1_16_R3.AttributeModifier>> entry : multimap.asMap().entrySet())
{
Attribute attr = Attribute.valueOf(entry.getKey().getName().replace("attribute.name.generic.", "GENERIC_").toUpperCase());
for(net.minecraft.server.v1_16_R3.AttributeModifier nmsMod : entry.getValue())
{
AttributeModifier mod = CraftAttributeInstance.convert(nmsMod);
meta.removeAttributeModifier(attr);
AttributeModifier clone = new AttributeModifier(UUID.randomUUID(),
mod.getName(),
mod.getAmount(),
mod.getOperation(),
slot);
meta.addAttributeModifier(attr, clone);
}
}
}
return meta;
}
I would advise against extending bukkit classes
Use PDC instead
Depends on the purpose
PDC doesn't create custom entities but rather stores custom information
You don't need a client mod for custom entities
you do if you want to change the look of said entity
or should say, the look of said entity with custom graphics XD
how do I get the raw data from a packetlistener or know what data to read from
Depends how you are doing it
If you aren’t changing the look you generally just need to store extra information, unless you are doing custom mob AI
unless they are creating a nms entity, but from what im reading is not what they are doing
If you are using ProtocolLib it has methods for getting the raw packet data
what is the method
if you are using NMS you would need to cast to get it
i am using protocollib
well they have documentation for their plugin
@limber dust no they are not, was just making a point there is times where it is valid to extend or implement bukkit classes/interfaces
ye
I do it all the time for custom player objects 🙂
makes sense
i tend to just have a getPlayer() method (mainly cause i use uuids, not actual players)
Hey guys im using the BlockPistonExtendEvent and BlockPistonRetractEvent to try and cancel the event if they move a specific block but when I am checking the event block I get the piston as the location instead of the block it is moving any ideas?
declaration: package: org.bukkit.event.block, class: BlockPistonExtendEvent
declaration: package: org.bukkit.event.block, class: BlockPistonRetractEvent
I can't seem to find it
Well as I said it just depends what you are doing. For most things it isn't necessary
The docs say the same
You don't extend bukkit classes unless they're obviously meant to be
I believe the only classes I’ve ever extended are JavaPlugin and BukkitRunnable
Yup, that's basically the extent of what it's meant to be
how do I get out of the asynchronous scope? I need to call a synchronous function from an anysychronous one
Is there a way to make an arrow (from Player.launchProjectile()) fly faster using a vector?
setVelocity
armorstand#setMarker(true) shrinks the armorstands hitbox to a minimum and also lowers the armorstand. Is there a way to prevent the "armorstand-lowering"?
@deft geode the length of the vector should determine its speed
ah
or the magnitude I think if you wanna get techincal
you are correct on magnitude @candid galleon
@hybrid spoke could you send an example?
high school geometry coming in clutch rn
trig is surprisingly useful
I think my teacher was just shit at teaching ngl
took me like 3 more classes to finally understand it
I'm more asking how to combine the vector with the way the player is facing
well you have the way that the player is facing with Player#getLocation.getDirection
I cant just use new Vector(3.0, 3.0, 3.0) because that's 1) not where the player is facing 2) i have no idea if they're near there
I am trying to get the contents of a Written book anyone know how I would do that I know it's a vauge question but ill give any details that anyone needs
that's already normalized, so you just have to multiply it by the power you want
@deft sedge assuming you have the ItemStack, you'd get its ItemMeta and cast it to Book
declaration: package: org.bukkit.inventory.meta, interface: BookMeta
I do that but I need to get the data from the pages
right, so you have the BookMeta ?
yes
nvm its not
ill show what UI hae so far
declaration: package: org.bukkit.inventory.meta, interface: BookMeta
BookMeta#getPages
basically just gets the meta if the item player is holding
quick tip, you don't need the else {
yea i know
aight
Just wanted to be shure lol
well can you try meta.getPages()?
yea
and then do I just do an if statement to check if the stuff is equal to this
i basically need to get the words form the pages
into a variable
sorry if it's obvious to you i'm kinda new 😅
right, so something like
List<String> text = meta.getPages();
would put the text contents of the pages into the variable text
no worries, it's always fun seeing new people learn
@sick ravine >:(
there ya go
and then I can do the same thing for specific pages right
hmm
List<String> pages = meta.getPages();
like get page and then a number
you know what Lists and Arrays are right?
yeah basically
not so sure on arrays
there is methods in the API for turning locations into vector's and second you definitely can just create a new vector and set it manually if you really wanted to.
trying to learn coding while doing something I enjoy
a list is basically an implementation of an array
for beginner purposes you can consider them similar
tldr the first page would be pages.get(0), second would be pages.get(1), etc.
if it was an array (it isn't), you'd do pages[0] for the first page
@sick ravine 🥜 gallery emojis imagine 😄
I think i can figure it out on the website you gave me
i can just grab the contents of specific pages and store them to variables
you could, depends on how you're using it 😛
List<String> text = meta.getPage(1);
would that get data of first page
or second if it starts with 0
it would get the second page
yea
generally indexes start at 0
bc it sarts with 0
i don't know if I formatted it right tho
it is red underlined
Oh i think i figured it out
it's this
List<String> text = meta.getPageCount(0);
and that would give the first page
to the variable text
getPageCount returns the number of pages
yea
so what's the 0 for?
first
but you're getting the number of pages
what is the difference between getPage and getPageCount?
idk
ill test
The first returns a list of pages
it
The second returns a number
o ur right
time to die
?
I jsut want to be able to get the words from a specific page and put them in a variable
which one is that
😳
the number of all the pages
I KnoW WhAT It Is RoLL Im TeAchInG
it confused me because it was under gtet page
it doesnt hurt to read methods lol
yea
so to get the contents of page 1 I would do String text = meta.getPage(1);
wich would return page 2 bc of how ther're numbered i know
in IntelliJ IDEA, if you hover over a method, its description will be highlighted
👍
Oh no
i got an error
BookMeta meta = (BookMeta) item.getItemMeta();
String testPage = meta.getPage(0);
player.sendMessage(testPage);
that is the code
is there anything wrong that is obvious?
error?
yep
ItemStack item = player.getItemInHand();
if(!(item.getType() == Material.WRITTEN_BOOK)) {
player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
return true;
}
else {
BookMeta meta = (BookMeta) item.getItemMeta();
String testPage = meta.getPage(0);
player.sendMessage(testPage);
here is the whole thing
i noticed that intelij put a cross through get Item in hand
would be useful if we knew what the error was
yeah because the player has 2 hands now
OffHand and MainHand
could that be the error
depends
invalid page number
