#help-development
1 messages · Page 1438 of 1
also what exactly are you trying to do?
he's making npcs
i could lend him some snippets but i think its more fun to find out
yo i like that nobody knows how to fix my issue
you dont have an issue
tru
yes but does this not translate into code for different purposes?
what you mean?
it's just that i never have used the bungeecord messaging system so i really don't know how to use it
what
the way i sent you its how you should do it
also dont expect to have PlayerInteractEnittyEvent here
you have to connect to the pipeline and catch interact packets
so I tried to synchronize the 'worldServer' variable to the 'server' variable, but you created a completely independent variable.
dont you see something similar in the name?
I may have described it as a bit confusing, I'll try this way and come back xD
WorldServer is the currently loaded world from the server
however your likely to use a command to spawn the npc
so you should use that with a player location
wich isnt much different than using what i posted just with world changed to player.getWorld()
also for your own sanity
hmm actually wait, I think I got it. Technically, codes with the same purpose. I'll try immediately and come back xD
(I have been taking java courses continuously for about 9 hours and my brain is about to burn. Sorry)
more important part
if(pack.c()==EnumHand.MAIN_HAND) {
if(pl.npc.getEntityId()==id) {
pl.qhandler.startQuest(p);
}
}
what will happen if you right click the npc
working with npc is no easy job as you will see
Did you write these to me? Because I mentioned another problem with NPCs xD
yep
the first one is how you will need to handle
the interaction with the np
npc
eq. right clicking it
im getting an error here for some reason
so no interaction?
yeap
in that case ignore them
you arent providing the right/enough arguments for the method
look at the method header
xD
I have another small problem with NPCs
Speaking of it, I want to talk about that as well.
do you mean something like this? ```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("SomeCustomBS");
player.sendPluginMessage(somePlugin, "BungeeCord", output.toByteArray());
}
```java
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord"))
return;
ByteArrayDataInput input = ByteStreams.newDataInput(message);
String action = input.readUTF();
if (action.equalsIgnoreCase("SomeCustomBS")) {
// execute some method.
}
}
```
so you need to construct a location
before teleporting
@onyx shale
NPC is creating as it should, but I still get this error. I do not understand
can u have idea?
think ur missing the serializer on the datawatcher
I can see there is a problem with (byte) but whatever I do I couldn't change it
would then SomeCustomBS be server 2 in that example?
my version is 1.16.5
also i have heard some from some people that there always has to be a player in each server for it to work and from other people i have heard vice verca
how would i do that
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
and yea you need a player to send the plugin message from
alright so if there was a player on server 1 but no player on server 2 would that work?
or does there have to be a player on both servers for it to work?
ischoo?
it insta kills
bless you
should work fine unless you want to send a message back to server 1
amazing, thanks for all the help man!
why do you even need datawatcher tho?
you dont rly interact with the npc,datwatcher is more of a metdata thing
to set armor skins or shit
any more issues LMK and i'll try and help (if im still online)
So I have a location and an Entitytype, how do I spawn the entitytype at the location
Location#getWorld()#spawnEntity
@sage swift how can I run it only 1 time?
Thank you Konjiki
I put a break; but it didnt work
@sage swift this is my last question
please bro
new Location(world, x, y, z)
oh someone already replied my bad lmao
still bit redundant
considering you can directly use clickedblock location
rather than building a new one
but i guess good practice?
so i have this now how would i tp them to the area
set it to a variable
new Location... creates the location but you need it as a Location variable to use it
sadly once we go into java basics ima head out
got it
also you really dont need to create a whole new location
event.getPlayer.getLocation.add(0, 1, 0) should do it
or if you want to teleport them on top of a block event.getPlayer.teleport(event.getClickedBlock().getRelative(BlockFace.UP))
@sage swift any way i could add the pitch and yaw
double num = Math.random();
if (num < .5) {
if (event.getEntity().getType() == EntityType.PIGLIN) {
Location loc = entity.getLocation();
event.setCancelled(true);
EntityType zilly = EntityType.ZOMBIE_VILLAGER;
loc.getWorld().spawnEntity(loc, zilly);```
a block doesnt have a pitch or yaw
whats up with this not working
i guess you can use the players one
true im dumb
How can I send pictures in here?
link with spigot account
you wanna verify your- 😦
so im trying to get the pitch and yaw of before the player gets teleported to the block
Because I need it here
how do prioritise right clicking a block over right clicking an item in hand? Like it right clicking the item opens inventory A and right clicking the block opens Inventory B, I want inventory B to open if the player right clicks the block with the item.
so do you think it will work this way?
PlayerInteractEvent?
Action.RIGHT_CLICK_BLOCK // they right clicked a block
Action.RIGHT_CLICK_AIR // they right clicked, but didnt right click a block (check if their main hand contains the item you desire)
i know thatsnot my question
oh yea, this worked, really thank you xD
Do you know a little about scripts? I want to ask a simple question
oh do you mean a block in the inventory?
depends what type of scripts
i think default scripts
Do you know of an option like on world enter?
ok what am i not understanding
define scripts idk what your talking about
actually this not about plugins, just the basic script question
i mean this: https://dev.bukkit.org/projects/skript
Sorry, a question completely unrelated to the channel content: /
I want to send a message like "hi" when someone is in the "oneblock_world" world
ahh you mean skript
oh
in that case nope,i only code in java
does anyone know how to lower the attack speed of an item
Somehow the zombies dont give me the effect
Can somebody see an issue?
duration is in ticks, so by saying 10 you;re saying half a second
is this expected behaviour?
20 ticks = 1 second
hey there so this is what i added to my GameManager class (since im making a minigame) though when i add the @Override annotation i get this error:
https://imgur.com/a/72F3fcJ
GameManager class: https://pastebin.com/e13QinFV
is it necessary?
oh right
public class SomeListener implements PluginMessageListener
implement the PluginMessageListener interaface
yep looks like it worked
How do I get all Player locations from a Mob event?
did you take a look at the link i replied with earlier? You also have to register the listener in onEnable(). It;s shown how to in that wiki article @muted idol
yea yea, already did that
alright cool
Why do zombies still drop items?
wdym
I'm trying to get all player Locations from any EntityDeath event
did u register event
Yea
show
🤷 try debugging
what is the name of the event when a player pops a totem
PlayerDropItemEvent and check if the Material is a totem?
are u sure
when people use totems they don't drop them 
is it PlayerItemConsumeEvent
EntityRessurectEvent
^ that if you mean use the totem
The plugin doesnt work....Zombies still drop items
ohh its okay
show latest.log
;-;;-;
you could try ```java
event.getDrops().forEach(drop -> {
drop.setType(Material.AIR);
});
but im not sure if it will work
pretty sure getDrops().clear() is right
Me too
Maybe its bcs I code for 1.7 👀
you're kidding
Unfortunately not

How do I get all Player locations from any Mob Death event?
Bukkit.getOnlinePlayers?
then how do I get the location?
what is your goal
to be cool 😎
cant help you with that
Hey! Im trying to create a plugin where you can click with a enchanted book on other item and it enchants it but for some reason it is super buggy. It dupes and is being weird
my code:
if (event.getCursor().getType() == Material.ENCHANTED_BOOK) {
event.setCancelled(true);
event.setCursor(new ItemStack(Material.AIR));
// Enchant
}```
Its an inventory click event*
I tried ```
if (event.getCurrentItem().getType() == Material.ENCHANTED_BOOK) {
event.setCancelled(true);
event.setCurrentItem(new ItemStack(Material.AIR));
// Enchant
}``` but it seemed to to less
use setCursor but delay it
thats how i did it and it works perfectly
even though setCursor is deprecated
this lines of code =>
@EventHandler
public void onSpawn(EntityDeathEvent event) {
if (event.getEntity() instanceof EntityCreature) return;
if (event.getEntity().getType() == EntityType.PLAYER) return;
EntityType type = event.getEntity().getType();
event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), type);
event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), type);
return;
}```
Litterally overloads the server. Is there something that keeps dying or what's wrong with it?
if thats overloading the server maybe it needs better hardware
or to get out of the 1970s
also youre checking whether a bukkit entity is an instanceof an nms EntityCreature
I have a lore tag on an item that makes it green "&a" but i want it green and bold
what do i put after &a
&l
for some reason in this plugin the text will be sent but the heath will not be set to 20 and the potion effects do not work.
Maybe delay it
how?
its cause right after the resurrect vanilla adds its own effects
Bukkit.getScheduler().runTask(plugin, () -> {
//potion effects here etc
}); or smtng
cancel EntityPotionEffectEvent where CAUSE = Cause.TOTEM
I tried with 5G still not working also, I feel as if it is overloading slowly contrary to what I said but this was before 5G anything you might know about?
how do i do that?
i dont see event.getCause on the list
you need to make a new method listening to EntityPotionEffectEvent
and run getCause on that
How long should I delay for?
👍
Still clones it
if (event.getCurrentItem().getType() == Material.ENCHANTED_BOOK) {
event.setCancelled(true);
Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
public void run() {
event.setCursor(new ItemStack(Material.AIR));
}
});
// Enchant
}```
Aight
are you in creative mode? make sure you're testing this in survival
Ah sheeesh works now. Danke danke
What's the best way to disable all commands for a player
So I'm having an issue with tab completion where only one option will show up for tab completion. Heres my code ```java
public class TabCompletion implements TabCompleter {
List<String> arguments = new ArrayList<String>();
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
arguments.clear();
arguments.add("day");
arguments.add("night");
arguments.add("afternoon");
arguments.add("midnight");
arguments.add("morning");
arguments.add("noon");
arguments.add("sunrise");
arguments.add("sunset");
List<String> result = new ArrayList<String>();
if (args.length == 1) {
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
result.add(a);
}
return result;
}
}
Any ideas?
ah
Also also StringUtils.copyPartialMatches
hey so i have an entity parent class, which would have things like ZombieMob extending it. now i also have a function that requires a child class (ZombieMob, SheepMob etc.. which all extend the main Entity class) how would i invoke a new instance on the given class? this is my current code which throws the InvocationTargetException exception
How would I change the StringUtils.copy?
public void spawnMobs() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if(maxcount <= 5) {
Constructor<? extends RPGEntity> constructor = rpgEntity.getConstructor(Location.class);
RPGEntity entity = (RPGEntity) constructor.newInstance(spawnLocation);
EntityManager.SpawnEntity(entity);
maxcount++;
}
}
ty
the rpgEntity variable is ZombieMob.class
oh shit i fixed it, found a nullpointerexception in my stack trace which let me know i forgot to assign the location of the mob i was trying to spawn, silly me
good job
got a quest system, dialogue system, mobs/spawning system ready looking good so far
Good luck
I have no idea what I'm doing
Still not working. Here's my updated code ```java
public class TabCompletion implements TabCompleter {
List<String> arguments = new ArrayList<String>();
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (arguments.isEmpty()) {
arguments.add("day");
arguments.add("night");
arguments.add("afternoon");
arguments.add("midnight");
arguments.add("morning");
arguments.add("noon");
arguments.add("sunrise");
arguments.add("sunset");
}
List<String> result = new ArrayList<String>();
if (args.length == 1) {
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
result.add(a);
}
return result;
}
}
You still return inside the loop
doesnt look very updated
so remove the return?
put it outside the loop
public class TabCompletion implements TabCompleter {
List<String> arguments = new ArrayList<String>();
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (arguments.isEmpty()) {
arguments.add("day");
arguments.add("night");
arguments.add("afternoon");
arguments.add("midnight");
arguments.add("morning");
arguments.add("noon");
arguments.add("sunrise");
arguments.add("sunset");
}
List<String> result = new ArrayList<String>();
if (args.length == 1) {
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
result.add(a);
}
}
return result;
}
return null;
}
like this?
This is my full cde
I forgot to add it
oops
Nice new lines
well this is the result so far (just gotta add spawnradius tomorrow) working pretty solid
for event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), type); How do I add PDC?
Save the returned entity to a variable
And then use variable.getPersistantDataContainer
||do it in one line||
? ok I'll try
I mean yes you can do that too
hey i was reading that
I wanted to try to figure it out my self before I ask sorry...
i've always wondered... does BukkitScheduler#runTask run at the end of that tick? or on the next tick? i've gotten some mixed responses about this
next thick
Sorry i was trying to screenshot
and if this is true why does it even exist if you can do runTaskLater(plugin, task, 1)
for that you can run it after a number of server ticks you pick
run task does it on the next frame only
no... runTaskLater does it once after a certain time
so runTaskLater(1) is equivalent to runTask
yes I think
depends if 0 on the runTaskLater is the next frame already or if 0 is the dame frame
Acctually, yes you are right
i wonder what happens if you put 0 in runTaskLater
there's no advertised exception for a non-positive delay
I don't know how the method works but i think it will just run at the same frame or, return an error
I assume it’s just a connivence method
is there any way to run the task at the end of the tick then? ive had a lot of cases where i would want that
What you need this for
just thinking about exploits that it could be used for :D
lol
No, scheduling is a best attempt system. Its not guaranteed to run precisely on schedule.
but, as @waxen plinth said, No, it shouldn't matter even then Think about it The server must run through all the events for the tick Then all the tasks for the tick Either that, or it must run through the tasks, then the events Either way If you schedule a task during an event It will be run before the events for the next tick
unless events are done before tasks
then the task is scheduled for after another iteration of events
if you modify the users inventory
do you have to do an updateinventory thing
i have heard someone say that somewhere
Ok, how do you do that
Player#updateInventory
Gives a HumanEntity
Just cast it to Player
It will always be a Player, I have no idea why it returns a HumanEntity
yeah if events run before tasks in a tick then scheduling a task for the next tick will run more events before the task
is this messy?
Yes
How would i fix it
make the first few return
^
My only guess would be npcs
?
if (item == null) continue;
if (NBTEditor.getBoolean(item, "ischecked")) continue;
if (!condition1) {
return;
}
if (!condition2) {
return;
}```
these?
Instead of nesting if statements
why?
It keeps your code flat
better readability
Instead of marching to the right of the screen it stays in one place
And it reduces scope changes
Break it down into more functions
I only do it if its like continue; or return;, etc
return;
Do it for returns too
You can make another method for sending the webhook
Also I would be careful with that
Looks like you're doing a synchronous web request
and thats bad why?
It will pause the server until the request completes
oop-
also haha discord.setTts
and how would i not do this
The easiest solution is to just spawn a new thread when you want to execute a web hook
Nice lib for async workflow
The next easiest is to just make a new thread and a queue of web hooks to execute
Second one is gonna be much easier on performance since there is overhead to spawning threads
Well the webhook only gets sent when a player has the specified item
But if you're not gonna be expecting this to be called a ton then the first way would work too
so it should be pretty rare for it to be ran
yea im not
new Thread(() -> {
//Code to be executed async here
}).start();```
Should i just do that anyway
Probably
Web requests can be slow
Server's got bad ping to discord? Oops, just froze the whole server for 200ms
new Thread(() -> {
//Code to be executed async here
try {
webhook.execute();
} catch (IOException e) {
plugin.getLogger().log(Level.WARNING, "Could not send webhook. Please check your webhook link.");
}
}).start();
like his?
this*
Yeah but indent it properly please
Select the code you want to indent
Hit tab
It will indent the whole section at once
Same trick with shift + tab to reduce the indentation level
you should also do this Runtime.getRuntime().halt(69);

in discord?
haha funny
oh, but the indentation is fine right?
Someone needs to slip a cyanide pill into geckos milk.
what
Don't understand why you're telling him to spawn a new thread
I mean
Instead of just using the scheduler
automod just deleted that i wonder why
Oh true
I forgot about that lol
lmao
Yeah instead of doing thread.start just do like
-.-
b lackspigot
Bukkit.getScheduler().scheduleAsyncDelayedTask(plugin, () -> {
//Code here
});```
Is that a banned word or something
thank you
yea
🅱️lackspigot
Great
its a website for fake spigopt plugins
damageable.setDamage(damageAmount);
this.setItemMeta(damageable);```
why can't i set the damage of this? i am getting this error:
```The method setItemMeta(ItemMeta) in the type ItemStack is not applicable for the arguments (Damageable)```
I've barely touched the spigot API in nearly a month cut me some slack
there is no method to get the Damageables meta
You cast to Damageable
Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable)
Gotta cast back to ItemMeta
thats depreciated no?
this.setItemMeta((ItemMeta) damageable)```
ok thanks
The one he sent is
thank you 😄
while (true) {
Bukkit.broadcastMessage(" ");
}```
but make sure you do it async so it doesnt interrupt the server
dos the players
Post your memes in general
nah use
while (1=1) {
}
while (while true())
{
}
🤯
plugin.getConfig().getConfigurationSection("blocks").getKeys(false).forEach(key ->{
how do i get the value of said key
config.getWhatever("blocks." + key)
thank you
it worked!
How would I change to clear weather
?jd
package index
is there a more effective/efficient way of spawning different types of the same mob instead of using random and a bunch of if statements
types of the same mob?
yeah so right now I have a random number gen and a bunch of if statements to spawn specific types of the same mob like a fast zombie or a strong zombie, etc
but is it possible to do it mroe efficiently
show code
im curious what you mean
so there is a random number gen
and based on the value it returns, you have a series of if,else statements that execute depending on the value?
{
Skeleton skeleton = (Skeleton) event.getEntity();
Random r = new Random();
int min = 0;
int max = 101;
int randomSec = r.nextInt(max-min) + min;
AttributeInstance attackAttribute = skeleton.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
AttributeInstance healthAttribute = skeleton.getAttribute(Attribute.GENERIC_MAX_HEALTH);
AttributeInstance followAttribute = skeleton.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
if (randomSec >= 0 && randomSec <= 19)
{
attackAttribute.setBaseValue(1);
healthAttribute.setBaseValue(15);
followAttribute.setBaseValue(50);
skeleton.setHealth(15);
skeleton.setCustomName("Weak Skeleton");
skeleton.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
}
else
{
if (randomSec >= 20 && randomSec <= 70)
{
healthAttribute.setBaseValue(25);
followAttribute.setBaseValue(50);
skeleton.setHealth(25);
skeleton.setCustomName("Skeleton");
Random random = new Random();
ItemStack weapon = new ItemStack(weapons.get(random.nextInt(weapons.size())));
skeleton.getEquipment().setItemInMainHand(weapon);
}
else
{
healthAttribute.setBaseValue(25);
followAttribute.setBaseValue(50);
skeleton.setHealth(25);
skeleton.setCustomName("Armed Skeleton");
}
}
}```
if there is a limited combination of possible entities (say strong zombie, fast skeleton) I would store them as individual entities in a collection, then use the random method to pick one of those to summon.
if there is an unlimited combination (random combo of potion effects + mobs) then I would store effects and mobs as separate collections, and pick one of each, then apply the selected effect to the selected mob
some things
- you have a nested if statement that doesnt need to be nested
Random.nextInt(int a)theint ais the bound, where 0 is the min. So no need for max + min- see above message for optimization. is this code just for the skeleton, or is it for every mob?
if you only need these effects applied for the skeleton, then clean up the nest and it isn't too bad code.
if it's for every mob, then try the solution above
Alright ty bro
Im trying to make something similar to H3M
but with more variety and attacks with the mobs
if(config.getString("punishment").toLowerCase() == "delete" || config.getString("punishment").toLowerCase() == "both") {
item.setType(Material.AIR);
plr.updateInventory();
}
if(config.getString("punishment").toLowerCase() == "nothing") {
NBTEditor.set(item, true, "ischecked");
}
if(config.getString("punishment").toLowerCase() == "command" || config.getString("punishment").toLowerCase() == "both") {
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), config.getString("command").toString().replace("%player%", plr.getName()));
try {
NBTEditor.set(item, true, "ischecked");
} catch(Exception e) {
}
}
}
i have both, and it doesnt seem to be working
in the config i have punishment set to both
# Valid options are delete, command, both, nothing.
# Delete: Deletes the item.
# Command: Runs a command on the player.
# Both: Runs Both.
# Nothing: Does nothing.
punishment: "both"
wait
leme print that exception
hmm no print
it shows up correctly on my yaml editor
(ignore the fact that it says delete there)
Strings are never compared with ==
String s = "test";
if (s == s) would return true
if (s == "test") would return false
if (s.equals("test")) would return true```
wow dude
you still here
i was searching for help in 2020
lol
xd
so i have a question: how can i structure my project?
im starting from 0 again
i forgot everything lol
since test is a compile time constant that'd return true
yes
Well true, but for example purposes of comparison use
ill have to build only 1 jar file that contains all the code (all plugins)
one jar per plugin
Depending on design you should really use one Plugin per purpose.
ok
no you should definitely just modify essentials to your liking
ie, one plugin for all chat related features.
here comes the craftbook crew to give a lecture on how monoplugins are better
what even is craftbook
an ancient megaplugin that does 4000 million things
so i might be dumb
item = NBTEditor.set(item, true, "ischecked");
Local variable item defined in an enclosing scope must be final or effectively final
rip
but idk how to fix this
wouldnt that mean i cant change it?
or don't use a lambda/local class
whats the context
no context thats the whole plugin
helps to see the rest of the class
you can change its contents, but not reassign it if final
When someone buys a vip on a Minecraft server, I want them to give an automatic discord role thanks to the automatic discord server plugin, how can I do that.
just use discord SRV
youll need a discord bot for that
but he's developing a minecraft server bro
lol
use some paste site
hey @wispy fossil how would I go about with storing the custom mobs in the collection?
I'll punch you gecko 🙂
dont setType air on an item
why
thx
then i run into the same error with the final thing
don't swallow Exception
use switch instead of a million if elses
i said its messy
i just need to figure out how to change the item while in the expression
don't swallow IOException either
But i dont ignore it
you do
It tells you smthng is wrong
you're not printing the stack trace
Yea, if somethinggoes wrong there its because of user error in the config
it is impossible for anyone to tell why the exception was thrown
IOException and Exception can be thrown for nearly any reason
print the stack trace after or in the message
ok
but how do i make NBTEditor.set(item, true, "ischecked"); be
item = NBTEditor.set(item, true, "ischecked");
In this case let's use an ArrayList
You have some entities right? With some attributes? (Sorry I don't have much experience withAttributeInstance class)
You would define an ArrayList where the <Type Paramter> would be <Skeleton>
Each item in the list would be one of the combinations of skeletons (or other mobs) that you have.
So for example, one item in the ArrayList would be the skeleton with low health, high damage - and another item would be the skeleton with medium health and medium damage, etc.
Then, you would select a random item from the arraylist.
This can be done using something like:
Skeleton theSkeletonToChoose = YourList.get(r.nextInt(YourList.size())
(i dont know if thats exactly right it's 2 am and im pulling that from my head)
This would allow you to:
- Customize each possible combination in an easy to access list
- Group everything in one object to get around some coding traps
BUT! I see you have different rarities for each type of skeleton.
One way to do this would be to have multiple ArrayList for each rarity of skeleton, and select which arraylist to choose from (An ArrayList of ArrayLists? 😮).
Or, store each type of Skeleton in a HashMap<a,b> and have a be the skeleton object with all of its attributes, and b be the rarity between 1 and 10.
Then, you can do a random roll between 1-10 for each skeleton, and if the random roll value is greater than or equal to the skeleton's rarity, then you pick that skeleton. If not, you try and select another one until one is matching. That's how I would do it.
But of course, all of this is overkill if you only have 3 skeleton types. There's no problem using a few if,else statements if there is only 3 or 4. If there are many more, then one of these is viable.
holy moly
wow thats alot
thats a lotta text
wow
how can i have a package inside another package
bcz when i try to move my package
inside another package
Alright alright thank you, this is very helpful
it renames the main package lol
intellij 😎
i have no idea i use eclipse
vc eh do brasil>:
i barely know how to work around the bugs of eclipse, let alone intellij
your brazilian?
nope i gotta get my name changed 🤣
lol
im gonna go donate $10 now
how would i get the slot an item is in?
an item may be in multiple slots at once
im already in a loop, of every item in the players inventory
how tf..
two identical items are for all intents and purposes the same item
get the contents as an array and iterate over its indices, rather than its elements
since im applying an NBT tag
for (ItemStack item : event.getClickedInventory().getContents()) {
yes but two identical items are for all intents and purposes the same item
how do i get what slot im on
yes, that is you iterating the elements
you can't, that way
you need to iterate over the indices
ItemStack[] contents = getContents()
for int i = 0;i < contents.length;i++
iterate the array and set the contents back to the inventory when done.
alternatively, you may search the inventory for a matching item each time but that is retarded
im just replacing one item
with the same item
but this time with NBT
aight fuck it, it doesnt matter. Im just gonna slap it into the players inventory
doesnt matter the slot
but again that is retarded
i wish there was a flag or something to disable the 'effectively final' shit for lambdas and local classes
literally just change the for loop to the one i gave and you have the index always
yep
?jd
package index
thanks
also just use the inventory addItem method
it'll do all of the space checking and slot finding for you and will return you the itemstacks it couldn't fit in
which you can then drop or whatever
ok
is there a more specific event than BlockDispenseEvent for when a shulker box is placed from a dispenser?
please tell me there is, please tell me there is, plea
um
i mean i guess i can get the adjacent block a tick after
just need to get the block that was placed
how do i make a 2 set bonus ability
huh
DispenseBehaviorShulkerBox is where to look if you have ideas of what to add
?paste
how to check if the player has a chestplate
does someone has an idea how to add items to inventory?
inv.additem(); or player.getinventory().additem(ITEM);
what
If you mean every material, there's a method that contains all enum values. Material.values()
just remember to cache it
because processing and formatting it each time is going to be expensive
there are like a billion materials
^
and the event is fired every time the player writes a new character in the textbox
I'd do a bit of filtering to remove the LEGACY_ materials but
there's also a bunch of other materials that you should never have as items
like wall banners and wall signs
piston heads and shit
I think there's a Material#isItem
when you use EntityCreature, EntityAnimal, EntityMonster, etc it requires the super() and you have to specify which entity, is there a way to set the EntityTypes to a variable or something like that?
like I want the specific function to be able to change entities so im not making duplicates of the same function/class to change the entity
idk if this makes sense
What’s the name of the class containing the method onBlockBreak?
then pass new RankEvents(), this
Implement the listener interface
That also lol
it will register all events?
Yeah but look what Konjiki said
the registerEvents method takes an object that implements Listener, looks through the methods its classes declare, and hooks every method annotated with @EventHandler into the event bus
therefore your RankEvents class should implement Listener, and you need to instantiate that class to create an object which you can then pass to the method
Random include 0 correct?
yes
the default minimum range of 0 is inclusive, yes
is there a reson why:
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleSneakEvent;
public class cTable implements Listener {
@EventHandler
public void cTable(PlayerToggleSneakEvent event) {
//try {
Player player = event.getPlayer();
if (player.isSneaking()) {
String name1 = player.getInventory().getHelmet().getItemMeta().getDisplayName();
String name2 = player.getInventory().getChestplate().getItemMeta().getDisplayName();
String name3 = player.getInventory().getLeggings().getItemMeta().getDisplayName();
String name4 = player.getInventory().getBoots().getItemMeta().getDisplayName();
if (name1.contains("CraftingTable Helmet") && name2.contains("CraftingTable Chestplate") && name3.contains("CraftingTable Leggings") && name4.contains("CraftingTable Boots")) {
System.out.println("ERROR2.EXE");
player.openWorkbench(player.getLocation(), true);
System.out.println("ERROR.EXE");
}
}
//} catch (Exception e1) { }
}
}``` wont work
okay so, say i have a BufferedReader
how can i get a String[] out of it?
this throws an ArrayStoreException because it fails to cast Object[] to string?
guess imma stick to while loops
what error? as you havnt; asked an actual question
i can't run command
you can see the https://paste.md-5.net/cehuvofanu.java
and you can see the https://paste.md-5.net/upicaqidun.bash
have you registered the command?
yes
CommandException: Cannot execute command 'kit' in plugin MyItemBuilder v1.0 - plugin is disabled.
wait
to check
my plugin is mykit
i was delete the myitembuilder in folder plugin
wait for restart the server
?paste
the kit command will not run because its registered with MyItemBuilder which is disabled
Is there a way I can send a message to console when my plugin is loaded?
Kit.java:27
?
something is null, probably the command isn't in your plugin.yml
String displayName = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Starter.Item-1.Display-Name")); = 27
then probably plugin is null
lol
this is a it tutorial with config
this.getLogger().info("blah");
i can't understand this https://www.spigotmc.org/threads/create-a-kit-class-with-config-file.273146/
try learning java first
i was try 1 years
lol
you have been trying to learn java for 1 year, but you don't know what null means
very impressive
and can I set the "prefix" of my plugin in the console, for example [TestPlugin] ?
If you dont know what null is after 1 year, you may want to choose another hobby. No offense
The prefix is whatever you name it in your plugin.yml
@wraith rapids
@tulip lodge
Is there a way of making falling blocks not turn to a solid block immediately on landing?
you have been trying to learn java for 1 year, but you don't know what null means
very impressive
؟
listen to the appropriate event and cancel it
i don't remember what the event is
blockformevent maybe
EntityChangeBlockEvent
yeah sounds about right
but that just removes the block outright
oh shit, really?
mmmm i don't think there is a good way of going about that
the server will try to form it into a block every tick it's there
maybe if you continually spawn a new one or something
protocol fucknuggetry might suit you better
But I do not know how to fix it
you learn java
oh no
fix what?
fix the null plugin
but i want to use colors
maybe in 1 more year you'll know how to make things not null
or know what null is to begin with
ok
lol
thanks for nothing Help XD
you're welcome
You cant ask for help if you wouldnt even understand what we tell you....
Then you would need to add a handler to your logger
owh
Something of an illusion breaker if they just dissapear you know
maybe just place them down
Create a class LogHandler extends ConsoleHandler and @override the publish method.
My only two ideas are
- Get the location and spawn a new entity there every tick over a certain amount of time
- Maybe when they are about to land give them a slight upward velocity repeatedly
Have never dealt with that really before, but maybe it will help
spawning a new entity will create flicker most likely
Probably #2 then
Logger logger = this.getLogger();
logger.setUseParentHandlers(false);
logger.addHandler(new LogHandler);```
also, what entity would you spawn there?
iirc the block doesn't need to be squarely on the floor to form a block either
it just needs to be in the general vicinity of the floor or something
yeah
oh
so they'd need to float like half a block midair
only solution i see is through protocol fucknuggetry
drop the outgoing entity destroy packet after cancelling the event and the entity will stick around
then resend it later to destroy it for realsies
or just leave it there forever
realistic debris
could work
@wraith rapids This is completely unrelated, but whats up with that username XD
alternatively just let the block be placed down
it's from a random string generator
ahh lol
mf was like why can't i use protocollib. dumbass hadn't imported it
smh
guys I made a scythe ability that can only works on items which have "Tırpan" lore but there is a error this is the code.
Your question makes no sense. They are circular
everything works fine but it oneshot
how can I fix this? I put a break to end of the code line but it didnt stop
then would the maximum possible pitch be 360 and minimum 0 like a cycle?
Use getFinalDamage to read the amount of damage to apply from teh event
A pitch of 0 represents level forward facing.
A pitch of 90 represents downward facing, or negative y direction.
A pitch of -90 represents upward facing, or positive y direction.
Increasing pitch values the equivalent of looking down.```
Yaw is 360
A yaw of 0 or 360 represents the positive z direction.
A yaw of 180 represents the negative z direction.
A yaw of 90 represents the negative x direction.
A yaw of 270 represents the positive x direction.
Increasing yaw values are the equivalent of turning to your right-facing, increasing the scale of the next respective axis, and decreasing the scale of the previous axis.```
this is all in teh javadocs
?jd
package index
👍
@eternal oxide amount = event.getFinalDamage(); lastDamage = amount; like this?
also, as you are applying damage yourself you need to use event.setDamage(0)
so you are not doubling up damage on the target
okey thanks I will try
Put this in the brackets
Is your plugin called MagmaBuildNetwork?
you are trying to call a constructor that wants a parameter without giving it any parameters
yes thats the main class
then this
Also aren't you registering the events twice there
yes he is
Ok, i have these entities that are not getting destroyed:
@Override
public void onPacketSending(final PacketEvent event) {
Player player = event.getPlayer();
PacketContainer packetContainer = event.getPacket();
int id = packetContainer.getIntegerArrays().read(0)[0];
if(this.plugin.newBlocks.containsKey(id)) event.setCancelled(true);
}
however they should not be in the hashmap to be cancelled
I have two classes for eventhandlers how do i register them both then?
normally
you do as you are. Register both
right now you are registering the same event listener twice
once in the constructor
and a second time in the main class
oh think i fixed it
wait so can i remove the constructor?
it gives no errors when i do
@eternal oxide
its not worked
double amount = evt.getFinalDamage();
I add this
if (amount > 2) return;
and this
whats wrong
why are you returning?
return monke;
because I want to deal the damage only 1 time
Get rid of your return
add event.setDamage(0);
then you apply the amount as damage in your loop
but we didnt use getFinalDamage
.
double amount = evt.getFinalDamage(); I wroted it but we didnt use amount
Hello
! is there any Furniture tutorials?
double amount = evt.getFinalDamage();
evt.setDamage(0);```
Source code is hard
just spawn some armor stands
Then in your loop where you apply damage to the entity you apply amount
ohh
okey
I got it now
@eternal oxide
it wont oneshot now
but still damage so much
when I hit a error occurs in the console
line 46
too small text, can;t read
com.destroystokyo.paper
?paste
should this work?
package io.github.FourteenBrush.MagmaBuildNetwork;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import java.util.logging.ConsoleHandler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
public class LogHandler extends ConsoleHandler implements Listener {
@Override
public void publish(LogRecord logRecord) {
Logger log = Logger.getLogger("Minecraft");
log.setUseParentHandlers(false);
log.info(ChatColor.translateAlternateColorCodes('&', "[&cMagmaBuildNetwork&r] &2[INFO]: Loading MagmaBuildNetwork"));
log.info(ChatColor.translateAlternateColorCodes('&', "[&cMagmaBuildNetwork&r] &2[INFO]: Done!"));
}
}
the last method
no
no, just use Bukkit.getConsoleSender().sendMessage()
Main line 46
@eternal oxide
I know I know
but Spigot already handles plugin enabling and disabling messages
it's useless expecially when Done! means nothing in this case
no, just use Bukkit.getConsoleSender().sendMessage()
no
((LivingEntity) entity).damage(amount, player);
do not send messages to the console
but you said this?
this is the line 46
use the logger
if they want colors they have to
they don't have to
the console processor supports colors
the way how the message ends up in the console is irrelevant
Make sure you check that the entity is a living entity
use your plugin's logger; that is the dedicated logger for your plugin and everything you print should go through it
not doing so will make it impossible to configure/filter your plugin's messages properly by the end user
that way you can add yoru color to your prefix
isn't there like a prefix value in plugin.yml or something anyway
Yes, he wants to add color so its a simple handler added to the logger
is there no need for implements Listener ?
that's not a listener class so no
well maybe i registred LogHandler wrong..
I gave you the code to add the handler
You shoudl be usign Damageable
after i removed the implements
because you're trying to register an event?
why are you trying to register your log handler as a fucking listener lmao
This is a new level
rack no
rack yes
if (entity instanceof Damageable) {
((Damageable) entity).damage(amount, player);```
:p
in your main class you java Logger logger = this.getLogger(); logger.setUseParentHandlers(false); logger.addHandler(new LogHandler);
@eternal oxide should I change all the (livingentity) to Damageable?
only where you are applying damage
but now there is no damage
then you did something wrong
I am so confused
probably imported the wrong damageable
import org.bukkit.entity.Damageable;
looks fine, except move evt.setDamage(0); outside your loop
I keep getting this error:
java-util-concurrentmodificationexception
with this code i believe:
for(Map.Entry<Integer,Integer> entry : plugin.blocks.entrySet()){
int id = entry.getKey();
int timeLeft = entry.getValue();
if(timeLeft > 0) {
timeLeft = timeLeft - 1;
plugin.blocks.put(id,timeLeft);
you are modifying the map while iterating over it
i know it is the plugin.blocks.put(id,timeLeft); but i do not know what to replace it with
yeah
okey
@eternal oxidewhat is this doing?
if (record.getLevel().equals(Level.SEVERE) || record.getLevel().equals(Level.WARNING)) {
System.err.println(message);
} else {
System.out.println(message);
}
use the entryset's iterator instead of a regular for loop
is the knockback still working but no damage?
or actually
ok, also is there a better way to update a keys' value
yeah ok thanks
Decides which channel the message goes. err or out
It should now be applying the exact damage you would normally do to one entity to all of them in range
Im getting this error and I cannot fix it
https://pastebin.com/YuUt2Cjb
Main File: https://pastebin.com/jxfseUwA
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
so what should I do
now my weapon damage is gone without aoe is gone because we used evt.setDamage(0);
What do you mean? hit with a weapon that does more damage
you can not instantiate your main class, you can not call its constructors
there must only ever be one instance of it
I tried
and that instance is created by bukkit
your setDamage(0) shoudl be outside your loop, but inside the test for Tirpan
okey lemme try
I have this but the color codes on the console does not work
@Override
public void publish(LogRecord record) {
String message = ChatColor.translateAlternateColorCodes('&', "[&cMagmaBuildNetwork&r] &2[INFO]: Loading MagmaBuildNetwork");
if (record.getLevel().equals(Level.SEVERE) || record.getLevel().equals(Level.WARNING)) {
System.err.println(message);
} else {
System.out.println(message);
}
}
I see no reaaon for no damage
both entities showed a hit damage animation
so you must be doing very minimal damage with whatever weapon you are using
I've no idea what you are saying
did you see the video
vidya
I did
.
unintelligible
Did you hear the hit sound
no, I have sound off
as you set damage to zero you are going to have to play the hit sound yoruself