#help-development
1 messages Β· Page 2132 of 1
if you modify the file manually while the server is down the changes will update on the plugin
wait
playerdata https://paste.md-5.net/tixazesabu.java
playerdata is at the bottom
k
What event is going before bungeecord trying to connect player to server?
i readed and tried but not work
PreLoginEvent, LoginEvent, PostLoginEvent, ServerConnectEvent
One message removed from a suspended account.
any idea on how to add bridge egg?
One message removed from a suspended account.
One message removed from a suspended account.
Just don't name ur main class main 
One message removed from a suspended account.
One message removed from a suspended account.
$YOUMAINCLASSNAME.getProvidingPlugin(YOUMAINCLASSNAME.class).getDataFolder()
One message removed from a suspended account.
Listen to it's throw and record the trajectory and then place blocks there
I want to and remove minecraft recipes from recipe book, is there a way to do it???
Hi i have a questions I want to make interact event when player clicked the chiseled stone brick but in if e.getblock() it can't equals ItemStakc
Can someone help pls
try getType() ?
Can getType can put the item id?
In 1.12.2
Chiseled stone brick need have Id like (byte)8
why can't I create a spigot maven project for versions lower than 1.8.9
you can try getBlockData() get BlockData object then use it to get it's Material
Lower than?
bruh im so stupid im forgot to register event
Ok thank you
Hello, I have one question, I have a system where when I click on a player with my item, it freeze the player and it open me a GUI, in this GUI i have an item and when i click on, i would like to kick this player, i can i get the Entity (so the player i've cliked on) in InventoryClickEvent ?
you can store the player object you have clicked and apply it to your button?
Am I getting it right? Because I don't really know what you want to do
LivingEntity mob = (LivingEntity) player.getLocation().getWorld().spawnEntity(player.getLocation().add(direction.getX(),playerY2-playerY,direction.getZ()), EntityType.WITHER_SKELETON);
WitherSkeleton gorr_killer = (WitherSkeleton) mob;
gorr_killer.setCustomName(ChatColor.RED+"THE GORR");
ItemStack helmet = new ItemStack(Material.NETHERITE_HELMET);
ItemStack chestplate = new ItemStack(Material.NETHERITE_CHESTPLATE);
ItemStack leggins = new ItemStack(Material.NETHERITE_LEGGINGS);
ItemStack boots = new ItemStack(Material.NETHERITE_BOOTS);
boots.addUnsafeEnchantment(Enchantment.PROTECTION_FALL,69);
Utils.gorr_equipment(helmet);
Utils.gorr_equipment(chestplate);
Utils.gorr_equipment(leggins);
Utils.gorr_equipment(boots);
gorr_killer.getEquipment().setHelmet(helmet);
gorr_killer.getEquipment().setChestplate(chestplate);
gorr_killer.getEquipment().setLeggings(leggins);
gorr_killer.getEquipment().setBoots(boots);```
It is suppose to summon wither skeleton with given armour but the skeleton spawn with no armour and there is not consile error?
I think it's the solution, I just want to get in my InventoryClickEvent the player who I cliked in my PlayerInteractAtEntityEvent
Make a copy of the equipment then apply all the stuff and then call setEquipment with your equipment data
Is this called when a vehicle is moved?
ok that was poorly worded
does an entity have to be riding a vehicle for this event to be called?
Or say a player gets off of a boat and the boat continues moving cause of momentum, would it be called then
or does the vehicle have to have a rider
there is no setequipment
π
yup
π
how do you remove one item from a stack in the inventory of a player
ok, thx
you mean you wanna add the player who you clicked in to your operation menu?
LivingEntity mob = (LivingEntity) player.getLocation().getWorld().spawnEntity(player.getLocation().add(direction.getX(),playerY2-playerY,direction.getZ()), EntityType.WITHER_SKELETON);
WitherSkeleton gorr_killer = (WitherSkeleton) mob;
gorr_killer.setCustomName(ChatColor.RED+"THE GORR");
ItemStack helmet = new ItemStack(Material.NETHERITE_HELMET);
ItemStack chestplate = new ItemStack(Material.NETHERITE_CHESTPLATE);
ItemStack leggins = new ItemStack(Material.NETHERITE_LEGGINGS);
ItemStack boots = new ItemStack(Material.NETHERITE_BOOTS);
boots.addUnsafeEnchantment(Enchantment.PROTECTION_FALL,69);
Utils.gorr_equipment(helmet);
Utils.gorr_equipment(chestplate);
Utils.gorr_equipment(leggins);
Utils.gorr_equipment(boots);
gorr_killer.getEquipment().setHelmet(helmet);
gorr_killer.getEquipment().setChestplate(chestplate);
gorr_killer.getEquipment().setLeggings(leggins);
gorr_killer.getEquipment().setBoots(boots);
It is suppose to summon wither skeleton with given armour but the skeleton spawn with no armour and there is not console error?
why casting it to a LivingEntity first and then a WitherSkeleton?
because it isnt static
Method isn't static
.
Opposite my bad
There was a command for that??
i thought
?learnjava I guess just link this then
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.
yes ! π
do you wanna try my API to help you build your UI? I think it may save you some time on this step
i can ! is it you that helped me with multiple-pages gui ?
of course
ahahaha nice
just dm you
I have this function that's supposed to return true if the inventories are the same but it returns false when it's should be returning true. what's wrong here?
for (int i = 0; i < this.getInventory().getContents().length; i++){
if (!(isSimilar(this.getInventory().getItem(i), inv.getItem(i)))){
return false;
}
}
return true;
}```
That's a bad way to compare If the inventory is the same.
so how should it be done
Use InventoryHolder
Hello! I was trying to check if a player have specific item, but method returns null.
I have stupidly simple code:
@Override // Yep, this is a predicate with player.
public boolean test(Player player) {
return player.getInventory().contains(stack);
}
Stack was loading from config file, using ConfigurationSerialiazable cause my class loads stack using it. With other items it works, with stone and some itemmeta - it fails... Checked - stack parameter loaded right..
Create an object that implements InventoryHolder, and assign that holder when you create the inventory, and then on the click event you can just check the InventoryHolder of the inventory.
what is InventoryHolder. what is this supposed to return
Wands holder = (Wands) clickedInventoryHolder;
if (holder == clickedInventoryHolder){``` like this?
You need to check the instanceof before casting otherwise it can throws CCE.
if (clickedInventoryHolder instanceof MyInventoryHolder) {
// That means the inventory is the custom inventory
// Your code here
}
but it says Condition 'holder == clickedInventoryHolder' is always 'true'
it is not InventoryHolder clickedInventoryHolder = event.getClickedInventory().getHolder(); Wands holder = (Wands) clickedInventoryHolder;
It's the same one
attackDamage:
max: 2048.0
```thats a value from the spigot.yml - how can i retrieve those values with the spigot api?
@EventHandler
public void canExplode(BlockExplodeEvent e) {
System.out.println("exploded!");
if(Start.getCurrentGame() == null) {
e.setCancelled(true);
return;
}
if(!Start.getCurrentGame().isStarted()) return;
e.setYield(0);
Iterator<Block> i = e.blockList().iterator();
while(i.hasNext()) {
Block block = i.next();
if (Start.getCurrentGame().getRemoveBlocks().contains(block)) {
//what to do here to cancel the block destruction?
}
}
}```
How do I create a Location when I dont know the worlds name?
this or extending the craftinventorycustom class itself is usually the best way
do you have any other information
event, command, etc
Can't, location must have a world
where could I get it from? only player?
okay thank you hmm
Mind telling us what you're trying to do?
yea
its okay I just wanted to know what possibilities there are to get the world so I can pick the best one
It's usually depends on what you're trying to achieve.
yes got it already thank you. π
hey with ProjectileHitEvent, how would i check if it hit a block or an entity
how can I only destory some blocks in .createExplotion
any reason this wouldn't work?
@EventHandler
public void EntityPickupItem(EntityPickupItemEvent e) {
if(ArrowPickup == true) {
if(e.getEntity() instanceof Player) {
if (e.getItem().getItemStack().getType() == Material.SPECTRAL_ARROW) {
Bukkit.broadcastMessage(ChatColor.WHITE + "<" + ChatColor.AQUA + "BlockyTel" + ChatColor.WHITE + "> " + ChatColor.RED + e.getEntity().getName() + " picked up the ball");
e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 300, 0));
}
}
}else {
return;
}
}
donβt think so
Does someone know the best way to detect when player collide or bump into a block?
else { return } omg
why do I get null exception when i click on anything that isn't in the inventory that i'm checking?
public void OnClick(InventoryClickEvent event){
Wands inv = new Wands();
Inventory clicked = event.getClickedInventory();
ItemStack current = event.getCurrentItem();
InventoryHolder clickedInventoryHolder = Objects.requireNonNull(event.getClickedInventory()).getHolder();
Wands holder = (Wands) clickedInventoryHolder;
if (clicked == null || current == null || holder == null || clickedInventoryHolder == null) { return; }
if (clickedInventoryHolder instanceof Wands) {
// That means the inventory is the custom inventory
if (holder == clickedInventoryHolder){
Player player = (Player) event.getWhoClicked();
if (inv.isSimilar(current, ItemManager.fireWand)){
player.getInventory().addItem(ItemManager.fireWand);
player.sendMessage(ChatColor.GOLD + "You now posses the power of fire!");
player.closeInventory();
} else if (inv.isSimilar(current, ItemManager.dragonWand)){
player.getInventory().addItem(ItemManager.dragonWand);
player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
player.closeInventory();
} else if (inv.isSimilar(current, ItemManager.lightningWand)){
player.getInventory().addItem(ItemManager.lightningWand);
player.sendMessage(ChatColor.YELLOW + "You now posses the power of lightning!");
player.closeInventory();
}
event.setCancelled(true);
}
}
}```
I don't know. the console says [13:32:28] [Server thread/ERROR]: Could not pass event InventoryCreativeEvent to MyPlugin v1.0 org.bukkit.event.EventException: null
there isn't "caused by"
you seearched cause by
it's a casting exception
not caused by
on line 27
whichever line that is
I'm guessing there
what is it that you're trying to do?
Wands holder = (Wands) clickedInventoryHolder;
this is the line
mhm
InventoryHolder clickedInventoryHolder = Objects.requireNonNull(event.getClickedInventory()).getHolder();
so clickedInventoryHolder is not an instance of Wands
yet you try to cast it to it
you've performed an unsafe cast
that's why you get the msg
I have a check for that the is outputed to the console and it says that it is an instance of that
System.out.println(clickedInventoryHolder instanceof Wands);
I don't see any check here?
discord didn't let me put it there because it is too long
you can use that
Hello, how can I detect if player press F key?
you perform those after the cast
try printing before the cast
they won't be printed if the cast fails cause the error will be thrown
you can't
only actions
like if a player hits an entity or something
before this? if (clicked == null || current == null || holder == null || clickedInventoryHolder == null) { return; }
no way to detect a specific key press
well you do the cast before that so yes
no point in printing after the cast has been peformed
I made it like this and it still outputs nothing but errors ``` @EventHandler
public void OnClick(InventoryClickEvent event){
Wands inv = new Wands();
Inventory clicked = event.getClickedInventory();
ItemStack current = event.getCurrentItem();
InventoryHolder clickedInventoryHolder = Objects.requireNonNull(event.getClickedInventory()).getHolder();
Wands holder = (Wands) clickedInventoryHolder;
System.out.println(clickedInventoryHolder);
System.out.println(holder);
System.out.println(clickedInventoryHolder instanceof Wands);
System.out.println(holder == clickedInventoryHolder);
if (clicked == null || current == null || holder == null || clickedInventoryHolder == null) { return; }
if (clickedInventoryHolder instanceof Wands) {...```
maybe I need to do the null check first
I think I found event.
(Maybe my question looks some confuse)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerSwapHandItemsEvent.html
declaration: package: org.bukkit.event.player, class: PlayerSwapHandItemsEvent
i think instead of doing == Material im gonna do instanceof
oh you're trying to detect when they swap hands
yes
then yeah that's what you need
just register a listener for that event
Thank you π
it's like this now it only gives me null exception error https://paste.md-5.net/lurowudalu.java @supple elk
it only gives me null exception when it is not the Wands inventory
if ClickedInventoryHolder is not an instance of Wands then the print statements will never run and a casting error will be thrown
yes
that is because you don't check what you're dealing with before casting
the InventoryClickEvent triggers when any inventory is clicked
then the first thing you try and do is cast
so for inventories where the cast isn't true the exception will be thrown
add this
Hi I was wondering yesterday, when accessing directories via ProcessBuilder, where does it originate?
if (!clickedInventoryHolder instanceof Wands) return;
before you cast
it should be like this (!(clickedInventoryHolder instanceof Wands))
public void OnClick(InventoryClickEvent event){
if (event.getClickedInventory() == null || event.getCurrentItem() == null || (Wands) Objects.requireNonNull(event.getClickedInventory()).getHolder() == null || Objects.requireNonNull(event.getClickedInventory()).getHolder() == null) { return; }
Wands inv = new Wands();
ItemStack current = event.getCurrentItem();
InventoryHolder clickedInventoryHolder = Objects.requireNonNull(event.getClickedInventory()).getHolder();
Wands holder = (Wands) clickedInventoryHolder;
System.out.println(clickedInventoryHolder);
System.out.println(holder);
System.out.println(clickedInventoryHolder instanceof Wands);
System.out.println(holder == clickedInventoryHolder);
if (!(clickedInventoryHolder instanceof Wands)) return;
if (clickedInventoryHolder instanceof Wands) {```
like that?
no
dude
you need to check what you are dealing with before you cast
do you know what I mean when I say casting
but your check required me to cast
(!(clickedInventoryHolder instanceof Wands))
I need to cast clickedInventoryHolder
no you don't need to cast it
you have an instance of an InventoryHolder
that is what inventory.getHolder() returns
you are trying to cast an InventoryHolder to an instance of Wands
which presumably is a child class of InventoryHolder
he found answer
so you must check if your instance of InventoryHolder is further an instance of Wands
before you cast it
^
also learn Java π€¦
yes
What is this?
Cause I get it a lot
it throws an exception if the argument is null
it doesnβt just magically make it not null like a lot of people use it as
so they should be checking if it's null
yes
mhm
kotlin on top
I don't understand what i am doing wrong. sorry if i'm annoying you
yes
with anvils
you can do that to everything
Y e s
the title is the name of the chest
Yes. The thing in the top can be changed using an anvil
but just why
Yea
Why dont u use the new switch
new switch?
the literal portable switch
idk I just hopped in with no context
Bestow upon me this sacred knowledge
switch (condition) {
case 1 -> {
}
}
Ye but ewer than the block type thing
Newer
Yep u r right
InventoryHolder clickedInventoryHolder = event.getClickedInventory().getHolder();
if (!(clickedInventoryHolder instanceof Wands)) return;
Wands holder = (Wands) clickedInventoryHolder;```
then what is the new?
Newest or Latest
What's more right
right
it says that it is always true if (holder == clickedInventoryHolder
Wands holder = (Wands) clickedInventoryHolder;```
Or even
if (!(event.getClickedInventory().getHolder() instanceof Wands wands)) return;
System.out.println(wands);
would work
because they are the same object
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.
what's a good ticking sound?
but onw of then is InventoryHolder and the other is Wands
I want something which sounds like a clock
for a countdown
like is there a noteblock click?
The dispenser success sound?
the sound of player hitting a player with arrow
nah that's too plingey
maybe some sound from a note block
yeah that's what I was wondering
go to wiki and get the names of the sounds of the note block
they are the same
Wands is a subclass of InventoryHolder
Wands is an InventoryHolder but with more stuff
so how to I check if these inventories are the same
you check when you cast
Use a BUTTON_CLICK and pitch it up to 2.
kk
if these inventories are the same size and has the same items in them
Compare the instances.
I would either use block.dispenser.dispense or block.note_block.snare
mk
I can experiment ig
was the copper_button supposed to be added only if the copper golem won the vote?
I believe so
π’
so basically i'm making a duels plugin and there's a bedwars kit what's the best way to track beds because one bed has two locations
Ehh, I suggest adding breaks
breaks?
It will now fall through and instantly hit all switch cases
Just move it back 2 spaces
literally wouldn't let me
if I backspaced it would go to prev line
returning would put it back in same place
Select the area with the mouse
I copied and pasted and it fixed
And then backspace
would have been a shout
any ideas
won't it just hit 1?
it's equals, not less than
Nope, switch statements have some weid behaviour called "fall through"
position of both blocks? Or position of one and rotation?
It executes the code in the switch statement until it hits a break; or the end of the whole switch statement
Always include a break statement when using the old switch statements.
right right, but it will actually only execute 1 case each time
but it will check all the cases anyway'
which is why you want to add breaks?
@supple elk
https://www.geeksforgeeks.org/fall-through-condition-in-java/
Try to read up on this, it might clarify it a boit more
No it won't. When it matches a single case it will execute everything
new statements just being a lambda?
Sort of. It looks a lot like it, but there are some changes under the hood when it comes to the new way.
int num = 3;
switch(num) {
case 3:
System.out.println("This is case 3");
case 3:
System.out.println("This is case 2");
case 3:
System.out.println("This is case 1");
default:
System.out.println("This is the default case");
}
Will print:
This is case 3
This is case 2
This is case 1
This is the default case
yeah I understand
int num = 3;
switch(num) {
case 3:
System.out.println("This is case 3");
break;
case 2:
System.out.println("This is case 2");
break;
case 1:
System.out.println("This is case 1");
break;
default:
System.out.println("This is the default case");
}
Will print:
This is case 3
I'm guessing you meant to put case3:, case 2:, case 1:
rather than 3 lots of case 3 lol
Jup lol, you caught me copy-pasting π
how do I compare 2 inventory type variables
:p
De lambda-style switch statements will prevent that by default
use case 2 {} its alot better compared to break;
so this is okay
?
yea like that
Yup! Like that!
Yeah, it's a lot better, but quite new syntax for developers who had been stuck with JDK 8 or JDK 11 until recently
.
What do you want to compare? The contents or it being the exact same inventory?
yea
option 2
If you compare the exact inventory, then contents donβt matter in terms of using that for your comparison. Itβs also less expensive to compare instances than the whole contents.
oh yeah, I had another weird question on a completely different topic
the first generic of GameType takes an extension of GameMap
how do I put actionbar messages without legacyTexts ?
gameType.addMap(this) is angry as the parameter needs to be the same type as the generic passed to it
You need to save an instance of your inventory somewhere in your code and use it for comparisons with other inventories.
is there a way to say that the first parameter of the passed in GameType must be the same as the class itself?
Have you tried to use inv1.equals(inv2)? What does that result in?
so GameMap must take a GameType<GameMap,>?
but if I had a class BoatMap which extends GameMap, it must take a GameType<BoatMap, ?>
thus solving the generic issue with addMap()
T extends GameMap
where?
Or in this case ? extends GameMap, in place of the first wildcard
I think you've misunderstood
It already has to be a ? extends GameMap because of the definition of GameType
I'm saying that I want that to be the same as the class which takes it as a parameter
its false when it should be true
so GameMap tkaes a GameType<GameMap,?>
and BoatMap (which extends GameMap) takes a GameType<Boatmap,?>
GameMap is like the abstract class
and I'd like to call generically in there to add the map to the gametype
Would this work?
if(event.getClickedBlock().equals(Material.LEGACY_SOIL)) {
event.setCancelled(true);
}```
in PlayerInteractEvent
getClickedBlock().getType()
or getMaterial()
whichever one
then .equals()
Yep, sorry.
Then in the GameType class, it should be something like public class GameType<T extends GameMap, ?>
Just asking if that event applies to this
yup, which it is
Used the move event for this before which is not very optimized
Oh I see what you're saying
the issue is in the parameter taken by the constructor of GameMap
I imagine it's not possible
How would I create multiple config files? Currently I have about 600 lines in my config and I would like to split that up a bit
Also, is there a event or something that I can use to execute a command once a player enters a portal (nether disabled)?
Currently have to do this (also, not ideal)
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
Location nether = p.getLocation();
nether.setY(nether.getY() + 1);
if(nether.getBlock().getType().equals(Material.NETHER_PORTAL)) {
p.performCommand("dm open menu");
p.setVelocity(p.getLocation().getDirection().multiply(0.3));
}```
?paste
https://paste.md-5.net/poqaluwumi.java
line 29 returns false when it should be true
because you are comparting an Inventory to an InventoryHolder
these are different objects
why this is not called when i rightt click the air even if i hold an item?
You can specify after the public and before the return type in the method, for instance public <T extends GameMap, G extends Game<T>> GameMap...
if i remove the ignoreCancelled it works fine
I think I've tried that but iirc it doesn't fire when nether is off
ok but I want the T extends GameMap to be the safe as the class itself
I want that T to be the class itself
I want a parameter for a GameMap<this.class,?> though that syntax doesn't work
How would I work around having about 20 config files tho? most existing methods for the config are aimed at the config with the name config.yml
I'm not sure that's possible, but then again I don't really understand the nature of what you're asking
right so
they're really not
its like 2-3 methods that exist for config.yml
right
That looks more correct. An Inventory is not an InventoryHolder, so it makes sense that they're not equal
I replaced this line with if (inv.getInventory().equals(event.getClickedInventory())){ and it still returns false
Does the PlayerInteractEvent work with going into a nether portal when the nether is disabled?
Oh I see
in the constructor of GameMap, I would like to add the map to a list of maps for it's corresponding type
You're creating a whole new inventroy and then comparing it to an existing one
by using the addMap() method in GameType
That would still have the nether world loaded which is not ideal for a lobby that is meant to house a couple hundred players
I assume that new Wands makes a entirely new Inventory?
I'm creating an inventory from my inventory class
I think I may have it. I have the .yml files created in my project in intelliJ, inside the code I create the folders they are in, then I make a new YamlConfiguration file in the classes I want them in and to load them I do configuration.load(file). am I missing anything?
it makes an inventory that has the items I want
the problem is the addMap() must take the type specified by the generic taken by GameType
so calling addMap() in the generic GameMap does not work
well
you copy the file within your jar to its destination (most likely the plugin folder)
Ah yes, but therefor it can never equal to an inventory that just got clicked
then yeah... load the contents from the file contained in the plugin folder
if the constructor of GameMap had to take a GameType which has the first generic be the same as the GameMap class, there wouldn't be an issue
ok thanks π
wdym how do i compare these
Only way I could see that happening is if you added a generic to the GameMap class
how do I put actionbar messages without legacyTexts in 1.8?
But what generic would I add?
And wouldn't the generic be the same as the class itself lol
In this case you will probably need to make sure that you already know what Inventory you want to listen for, or compare all the items inside the inventory
GameMap<T extends GameType>
help π
so i need to check if all the items in these inventories are the same?
That is an option
you added if (item != null)
why would it call when you hold an item
donβt do that
just compare the instances
the >>> METHOD <<< is not even called
probably because the first predicate you test is true
dude
why are you checking the action like that
it looks pretty weird
that will not solve my problem
It doesn't. I suggested that before I understood the whole context lol
right lol
how are you checking that
debug
Inventory here = this.getInventory();
if (here.getSize() != inv.getSize()) return false;
for (int i =1; i <= inv.getSize(); i++){
if (inv.getItem(i) != here.getItem(i)) return false;
}
return true;
}``` like this?
I suppose the .yml files I want to load cannot be inside their own folders?
this error disappears when I move it out of the folder
Afaik there isn't a way to do what you want, you'll have to find something else
If you have custom items that can work and would be safe to use. But it is better to keep track of the inventory instances themselves and comparing them when needed
If you open that inventory from your plugin, you probably can keep track of the instances
then they probably werenβt the same instance
Yes, but that's because you create a new inventory
right
It just means I have to manually add it everytime I add a map
Every time someone clicks in a Wands inventory, you create a new one to compare against
But it did not exist before the event was created, thus could never equal the clicked inventory
if the inventory changes when I click it so i can't check it
tf
why would the inventory change when you click it
.
if you are creating a new inventory it obviously wonβt be the same instance
ok
whats going on
idk
neat
can we boss bar for other mobs?
you can create a bossbar manually
You'd need to track the progress manually, I think
Check the createBossBar methods in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html and the class https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/BossBar.html
declaration: package: org.bukkit, class: Bukkit
declaration: package: org.bukkit.boss, interface: BossBar
would using paths like this cause problems when used on different operating systems?
Do scheduleSyncDelayedTasks need to be cancelled manually after being ran using cancel() or do they do that automatically?
they end
think of those tasks as their own threads (but, like... synced to the main thread)
So they don't stay in the server's memory after they get ran?
Just asking because I'm trying to optimize basically everything I can rn
I don't know them too much but I would think they just get thrown out by the garbage collector when theyre over
Got it, thank you
not a guarantee tho
it wont run again, but anything after cancel() will still get run
if you dont want that to happen just add return;
Well they only get ran once, my concern is them staying in server memory (if they do, anyway)
its delayed task, not repeating
Β―_(γ)_/Β―
Good morning, you guys! One question, Iβm developing a credit card plug-in where every player to whom a card was created has a credit card number. So I did to get values in both ways like this:
Playername: card: 544152418545 544152418545: owner: Playername
But it seems rather unseemly as in the future I would add something like limit levels of card withdrawals and this would seem to be very unseemly in my opinion. How do you think I could do for better storage? Thanks even if youβve only read! β€οΈ
make the players uuid, not name, a configuration section, and then put their credit card number, balance, expiration, or whatever else you want into the config section
The little problem is that I would like to make the cards stealing from other players and I would like them to be able to withdraw from other peopleβs accounts if they have their own card
whatβs the problem with that?
uhhhhh so I can put the uuid in the credit card item instead of the cardnumber
gotcha
well then inverse it
make the credit card number the configuration section and have the players uuid be a property of the section
would be possible as well to not change it but slightly more tedious
So it'll be like that:
UUID-8485-894854:
holder: Sussybaka
expire: 02/02/02
card: 45254455656
45125241541214: UUID-54854854
right?
no
you just make the card number be the configuration section key
and then replace holder with the players uuid
you never want to use names for storing players info
why not
because people can change their names
uuid:
card-number: 12345
credits: 100```
yeah
uuid will never change
yea but what if the player isn't premium
as in a cracked account?
yep
Doesn't matter. Offline UUIDs also don't change.
Also, don't support cracked servers. Simple as that.
oh okay
well making plugins cracked accounts is a whole new discussion, but yeah just read above
thanks β€οΈ
Hey, can someone walk me through making my own external library? I've tried, but I don't know how to import it properly.
Yea make a project upload it by use maven or gradle repository manager like repsy jitpack o
Then add library as dependency and shade it
enjoy your new external lib
okay wait so I make a new gradle project, in the main java class I write my code, then export it, add it as a module or a library?
You can have as many classes as you want
Don't need to do anything special a lib is just a collection of apis and utils
Just slap em together bundle it and depend
to export the gradle project do I build artifacts? And then to shade it what do I do? I've never done this before
You need to run the build task
so just normal Build > build project?
Are you using Intellij?
yes
It's literally as simple as making a project with a bunch of utility classes. Using maven install, then importing that maven project into another project.
There should be a gradle tab on the right side. Open and Tasks > build > build
how to set player suffix via bungeecord?
I know it must be simple however I'm not familiar with any of these tools (Maven or Gradle) and most resources I've found online assume you know
as for shading you need to use Shadow. However I'm terrible with it and I always struggle so I can't really help with that
uhh i kinda forgot but should i add the spigot api via the maven dependency thing or just manually add the jar?
Ah, no worries, I haven't used gradle, but I could walk you though how to do it with maven.
alright, that's fine, let me start a new maven project then
maven dependency.
Spigot Repository:
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
Spigot API:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
More or less.
NMS and Spigot jar
It also installs the spigot api into your local maven repos.
for what do you need the spigot jar then?
Running the server
for this i wanna make a explosion occur when a torch is left clicked but for now i just want it to be if its clilcked in air as a test and im not sure what to do on the e.getClickedBlock because im not sure if air is a block
public void TorchBomb (PlayerInteractEvent e){
Player p = e.getPlayer();
Action action = e.getAction();
ItemStack item = e.getItem();
if (!item.getType().equals(Material.TORCH))
return;
if (action == Action.LEFT_CLICK_AIR) {
World w = p.getWorld();
int Integer;
boolean Boolean;
w.createExplosion(e.getClickedBlock().getLocation(), Integer = 1000, Boolean = false);
}
}
The Spigot jar pre 1.18 could be used for manually dependencies, but now that it's a bootstrap jar, you need to include the extra dependencies, or just use maven.
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
a bed has two locations right
Creating an External Library via Maven
how can i cast a mob health in bossbar?
What is this?
w.createExplosion(e.getClickedBlock().getLocation(), Integer = 1000, Boolean = false);
Just pass the raw values as the parameter, how did that even compile?
Also, creating an explosion in mid air may not do anything. It'd be better to change it to happen on the ground to verify that it works.
idk why it says 1000 but it worked last time
the integer is 1000 which is how powerful the blast is and the boolean is if fire works
dunno what a bootstrap is
i had to do that some reason according to the docs
have a runnable that keeps checking for their health and displays it to the bosbar
No no, I mean, why not just
w.createExplosion(e.getClickedBlock().getLocation(), 1000, false);
I'm just confused on how your code even compiled the way it was.
ive done that already but when placed
oh my god i am a idiot
its been a while since i did java lol
the variables were defined above that
better that than going from rust to java
Think of it as a server started instead of the server itself
The server and it's dependencies are then stored inside the jar as jar files that the bootstrap launches
ah a program that launcher another?
anyone know how to make a shaped recipe where I can get the enchants of an item such as a sword used in the recipe and apply them to the resulted item as well?
so ive gotten an ideo to make the torch a bomb device but i want the explosion to be on the ground so if you are higher in the air you would pretty much do nothing because you dont have reach
im not sure what to do to cause that "reach"
is this even a feature
probably
ive scoured the internet
ive only found things about ench items being crafted and outdated stuff
look in the docs for something about crafting and then implement a enchant thing
into the code for the crafting
setIngredient doesnt have any that takes in an ItemStack
this has got to be the strangest way i have ever seen expressions being used
lol
true lol
ive lost all of my braincells because i have no idea how this api works and that was from a begginer from the internet
im trying something else but i accidently set it to 1000 as the blast radius so my server crashed meaning it worked
but im gonna do a normal test
add the players direction vector to their location (adjust it as neccessary) and then spawn the explosion there
should have the similar effect to clicking a block
ok it works with this
public void TorchBomb (PlayerInteractEvent e){
Player p = e.getPlayer();
Action action = e.getAction();
ItemStack item = e.getItem();
if (!item.getType().equals(Material.TORCH))
return;
if (action == Action.LEFT_CLICK_BLOCK) {
World w = p.getWorld();
w.createExplosion(e.getClickedBlock().getLocation(),100,false);
}
}```
as a left click on a block
ill add another statement for air later
ok
using math? or is there methods
you can just add a vector to a location with #add(vector)
interesting
anyone have answer
its complicated is all i know since its a plugin instead of a mod
There's no way to do that with default recipes to my knowledge
π
You have to intercept the event
i dont think it is since its a event
how to cast health in int
wdym by that
i meant int
player.gethealth in int
like
im not sure how to add a vector to that
typecast?
yup
just do
(i just started plugin dev)
you can make it eequl to a int
https://paste.md-5.net/yaloyexino.apache
So I have t his error that is spammed in my console, but everything works fine in game, it still is annoying that it spams everything, could I have some help ?
it worked π
Location explosionLoc = player.getLocation().clone().add(player.getDirection().multiply(range));
nice
hm
oh wow ty
much simpler than i thought
yea
arent locations immutable in newer versions?
i think theyre mutable
at least in whatever version i use
if not just remove the .clone
hmm ye youre right
is there a way to make players be able to apply books with UnsafeEnchants using anvils then?
in 1.17.1
use lore
i never learned how to do that
what shoudl the range be
pdc would be a better idea than lore
are enchants basically just lore?
no
what pdc
?pdc
I used lore for custom enchants, thought it was the same
Not really. The PDC has stayed pretty consistent.
im still messing with vanilla enchants just higher levels
There are expansions for data types though.
https://github.com/JEFF-Media-GbR/MorePersistentDataTypes is one of them.
https://paste.md-5.net/yaloyexino.apache
So I have this error that is spammed in my console, but everything works fine in game, it still is annoying that it spams everything, could I have some help ?
its not a great idea since you might want to add custom lore to the item
whats the full exception
i just check if the lore contains the enchant, I can do both
what do you mean ?
im not understanding
does it not say Caused by: <>Exception anywhere
Oof, 1.8
it's been spamming my console for 1 hour so sending the whole thing sounds compliacted
yea i dont really agree
thats about as good as 1.8 gets
?paste
Yes it does.
https://paste.md-5.net/efajemosow.apache what's the point lmao
What's on line 49?
in order to know anything about it we need the exception
pvp server so yk
oh
null pointer
whats kiwiwands
if (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Β§6Fireball wand")) {
the class ?
That's why
the item in the player's hand is null
Likely no null check.
do you ever check if the player has something in his hand
yea thats fine
alr thanks
problem i have: i want to make a sword apply wither 2 effect for 5 seconds to the enemy, but the listener doesn't recognize the lore
doesnt recognize?
loop the lore lines
maybe the chat colors messes it up
well exactly
oh bruh
It's deprecated.
just a deprecation warning
alr thanks ill test it out
u think it should work tho?
ok ima try that
Have you tried debugging it with a bunch of souts?
Yes
no idea tbh
bruh
oh
^
ty for clarification
export as jar file right
i havent dont this in months
*done
Yes, you want a jar file.
Uhh, well besides the change about becoming a bootstrap jar, no. The jar should download all the dependencies it needs, so this may be another issue.
hm
before i just went to the spigot files and messed with the permissions
everytime i booted up the server
Permissions for the jar itself or the directory in which it resides?
the file in the repository
I'm confused. How are you trying to run the spigot jar? Linux or Windows environment? Is this on your own computer, or a remote one?
Then why do you need to modify the permissions for the jar file? As long as the files are under your account, you shouldn't need to mess with them.
hi! i need to get an image from a url, i have this url https://crafatar.com/avatars/97fd4734-b7c8-4cb7-a0a0-ca682aa45f06 which gives me my minecraft head icon, how could i get an image out of this url?
uh
for what purpose?
sometimes u can just store it as a png instead of having to use a url
i need to make a message with this image
Well, if you can, I'd recommend resetting the permissions if possible. Otherwise, create a new directory and put a fresh copy of the spigot jar from buildtools in there. Then try to run it normally.
in console?
yeah but the problem is i want this to work for every uuid of the players in my server
what kind of message
exactly
like this
Pretty sure there is a resource for that somewhere on the forums.
or this
i didn't find anything...
take a look at this
thank you
ya np gl
i did that like
um, somethign up with Github auth? it tells me my password is wrong and my email is not the main email
the bt thing a long time ago
Location explosionLoc = p.getLocation().clone().add(p.getDirection().multiply(range)); in this i got a error on range
I don't think so. I'm still logged in, so not 100% sure.
i used that as a placeholder for the value you want
oh ok
what did u put instead of range
ex: you want it to be 2 times as far, change it to 2
should i set that as int
Desync location issue? Whenever I respawn these armorstands, it shows their location inaccurately and fixes after relog - is there anyway to fix this or do I have to manually force a chunk update?
https://cdn.discordapp.com/attachments/493232350029807616/972904332506857502/5ojjpDEif8.gif
oh
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Just download the jar, and run it with the proper flags.
and i also have a error on .getDirection
alr ill give it a go
might be the wrong method name
is that facing?
its this now' Location explosionLoc = p.getLocation().clone().add(p.getFacing().getDirection().multiply(100));
Pretty tame compared to mine.
Tab stacks are fucking great.
Hey quick question. How can I save a world / trigger /save-all via code?
jesus
idk what getFacing does, but i use getLocation.getDirection
dude you need to start from scratch
ok
dont know if getfacing would make a difference
probably where the player head is facing
think there something for commands out there but i dont remember
did you register the listener
You might be able to use Bukkit#dispatchCommand()
EDIT: There might be a better way to save worlds with the World class.
is the event triggering?
if it is its probably an issue with .equals(Lentus)
are you sure of that
@kind hatch what do i do with this
Run that in your terminal/console.
oh
bukkit.broadcastmessage("" + player.getInventory().getItemInMainHand().equals(Lentus))
Yes
oh
Normal command prompt.
You need to run the command in the same directory that BuildTools is in.
uhhh
Or specify the full path to where it's located.
so ive done this but it seems to not work Location explosionLoc = p.getLocation().clone().add(p.getLocation().getDirection().multiply(100));
where is it usually
neat
typo lol
Lmao, normally it's in your downloads folder.
alr
downloads digging
4 months ago
told u its been a while
I mean, you probably have one labeld BuildTools (1).jar
Which ever is the latest, you will want to use.
Well, it's probably somewhere else then.
i tried to left click but nothing happend unless im in reach heres full code ```package com.tuwtle.TorchHandler;
import com.tuwtle.testplugin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class TorchHandler implements Listener {
public TorchHandler (testplugin plugin){
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void TorchBomb (PlayerInteractEvent e){
Player p = e.getPlayer();
Action action = e.getAction();
ItemStack item = e.getItem();
if (!item.getType().equals(Material.TORCH))
return;
if (action == Action.LEFT_CLICK_BLOCK) {
World w = p.getWorld();
w.createExplosion(e.getClickedBlock().getLocation(),100,false);
Location explosionLoc = p.getLocation().clone().add(p.getLocation().getDirection().multiply(100));
}
}
}```
im not familiar with cmd
Your browser should tell you where it downloaded to.
but idk how to tell cmd where
that is gonna be very very very far away
100 blocks?
what happends if you go out of the 100 limit
i have to go eat breakfast lol its past noon where i am brb π
idk
i dont think 100 is the limit
probably wont work
you're just creating the explosion very far away
Your browser has something that shows you all of the files that you have downloaded in your session. Since I use vivaldi, this is how it looks for me. When I click on one it gives me information about it.
As you can see, the file I have selected was downloaded to my Downloads folder.
on chrome its like ctrl j
Is it possible to get Block of chest on InventoryCloseEvent ?
So I can check custom data in PDC on that block.
using the inventoryholder maybe?
what is the or operator in java
||
you can just download the latest version and this time remember the path, download it won't take you too much time
BRUH now i understand what that method is doin
i was like an inventory which has a location huuh
@wary harness
oh cool
World w = p.getWorld();
w.createExplosion(e.getClickedBlock().getLocation(),100,false);
Location explosionLoc = p.getLocation().clone().add(p.getLocation().getDirection().multiply(5));
}```
updated code
thanks
if you left click a block its gonna spawn like underground just so you know
not where they actually clicked the block
wdym?
with the range?
yes
With the way you have your code, it's not going to spawn where you click. It's due to you changing the location of the explosion.
just adjust it until it feels right
probably
You mentioned that you wanted to check for distance/if the player is down at someone on the ground. There are some methods that you may want to look into.
Player#getLineOfSight() - Gets all blocks along the living entity's line of sight.
Player#getTargetBlock() - Gets the block that the living entity has targeted.
Player#getTargetBlockExact() - Gets the block that the living entity has targeted. This takes the blocks' precise collision shapes into account. Fluids are ignored.
i need a plugin for my gamemode
and dm me if interested
also i can vc with you to talk about it if needed and i can also show you my server so you can get a better understanding of it and how the game works etc
https://paste.helpch.at/ezewobayeh.sql
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
i am not allowed to post in there
Well this isn't the right place
oh ok thats useful
i think the second one would work
how would i use that method though?
is it worth it to create an api to make plugin messages more structured
or has someone already done that
what kind of plugin messages?
the ones between servers? (f.e. Player#sendPluginMessage)
primarily for like bungee
would make sense to write a kind of wrapper for it