#help-development
1 messages · Page 1356 of 1
yup
debatable
the amount of broilerplate and shit visual bukkit creates
when it makes the code
not sure if its going to be faster either
lol
lol
@jaunty epoch maybe look up ur problem on the interwebz or find a server that's deticated to that sort of stuff
ok
dm me
cannot do that
and send me it
please no ban me bot
ty
I saw that for one second lol
the bot's already mad at me for spam
but I don't even spam
spam
o7
Hello, I am receiving an issue where my listener will not be called for some weird reason. Does anyone perhaps know any suggestions? Here is what my code looks like:
public class Main extends JavaPlugin {
public static Main instance;
public static HashSet<Player> players = new HashSet<Players>();
@Override
public void onLoad() {
instance = this;
Bukkit.getServer().getPluginManager().registerEvents(new MyListener(), this);
}
public static Main getInstance() {
return instance;
}
}
public class MyListener implements Listener {
public static void onWalkEvent(PlayerMoveEvent event) {
Main.players.add(Bukkit.getPlayer(event.getPlayer().getUniqueUuid()));
event.getPlayer().sendMessage(ChatColor.GOLD + "You have walked!");
event.getPlayer().sendMessage("test");
}
}
I am new to Java
Your listener methods cannot be static
They also should be annotated with @EventHandler
Oh
public class Main extends JavaPlugin {
public static Main instance;
public static HashSet<Player> players = new HashSet<Players>();
@Override
public void onLoad() {
instance = this;
Bukkit.getServer().getPluginManager().registerEvents(new MyListener(), this);
}
public static Main getInstance() {
return instance;
}
}
public class MyListener implements Listener {
@EventHandler
public void onWalkEvent(PlayerMoveEvent event) {
Main.players.add(Bukkit.getPlayer(event.getPlayer().getUniqueUuid()));
event.getPlayer().sendMessage(ChatColor.GOLD + "You have walked!");
event.getPlayer().sendMessage("test");
}
}
like this?
Looks better yes
alright I will give it a shot
Tho Bukkit.getPlayer(event.getPlayer(). get UniqueId()) seems just. Like. Why XD
Oh
Like event.getPlayer already returns the player
I see
so unecessary tight coupling
right
Yeah it seems to work
But wait
why do people say not to use static?
some other people in other discord told me that
for set
What's a good redis library to use for a plugin?
you are overriding an existing method in the Listener so your method footprint must match
No he isn't
Static is fine when used correctly.
this kid looks cool https://github.com/PulseBeat02
This is not an overwrite
@eternal night all plugin implementations of listener are overiding the Listeners method.
No. Open the listener interface
Find me those methods
That are overwritten
Please
stick my dick in her mouth, I call that oral sex. say memes out loud, I call that oral keks
Switching accounts like a true hero eh XD
Oh I see what you are saying, they are annotated not overridden
Yes
So you wasted my time
Ah.
But yeah. Elgar the listener class is traversed using java reflections to find all methods annotated with Eventhandler
So it isn't really overwriting
More like, following a schema.
Yep
Hence why static doesn't work, because static methods are not considered in that traversal
is there a way for me to get a function to return two different types of variables
yes
How?
create a return type object that holds two
ok
What points should be considered in the MySQL vs Mongo argument? I wanna know why we don’t just all use mongo (although sql is older and therefore has more users and people comfortable with it)
but what do i set the public thingy to
I guess also all data is maintained via the same commands
I want to return an item meta
then set the return as public ItemMeta
static is really for utility methods
k
it's mad a tme
you need a method name
public ItemMeta methodName() {}
k
What changes do I have to make to this, i'm trying to check the players inventory for the specifc material that is given
I found this code on bukkit forms so it's probably wrong
@eternal oxide
or anyone else
if you just want to see if a material exists inv.contains(Material)
to see if a certain amount exists inv.contains(Material, amount)
Javadocs are your friend https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/Inventory.html
well I want to get the meta of that certain material, but I think i figured this one out
thanks!
i am trying to make a function bc this will probably happen a lot
my goal for what i'm doing now is to remove certain item from the invenotry
so i think if i can get the meta of that item, i can then remove it
ItemStacks have meta not Material
oh
my goal is to be able to do stuff with things I find in their invenotry. Like for example, If I find a book I wanna add a page to said book
how would I do that?
if you just want to remove if found use the contains method to make sure it exists, then use inv.remove(Material)
ok
all the methods available for Inventories are in those javadocs
ok thanks
@EventHandler
public void onLogin(AsyncPlayerPreLoginEvent event) {
if (config.contains("verify." + event.getUniqueId())) {
return;
}
String code = ThreadLocalRandom.current().nextInt(100000, 999999) + "";
idCode.put(event.getUniqueId(), code);
codeID.put(code, event.getUniqueId());
codes.add(code);
ideas why the last line codes.add(code); doesnt't add anything?
private List<String> codes = new ArrayList<>();
in a JDA-Event
if (!codes.contains(code)) {
channel.sendMessage("Dieser Code existiert nicht. Bitte versuche es erneut oder kontaktiere einen Admin.").queue(); // code doesn't exist.
System.out.println(codes);
return;
}```
it just prints out ```[]```
They use the exact same instance of your listener I suppose ?
idk
Creating an instance of this class twice would explain the issue
How do you not know lol XD
maybe i am? :o
builder.addEventListeners(new ConsoleLogListener(), new VerificationManager());
Bukkit.getPluginManager().registerEvents(new VerificationManager(), this);```
is that the reason why?
Yeah no you are using two different instances
Yes
Your listener instance of the class is mutating the list it owns
ah nvm
While your jda instance is just vibing with an empty list
VerificationManager vfManager = new VerificationManager();
builder.addEventListeners(new ConsoleLogListener(), vfManager);
Bukkit.getPluginManager().registerEvents(vfManager, this);```
so i guess, this fixes it?
No problem XD it's a very common mistake when not using static for once
i am still a bit stuck at static abuse tho... but outside of that, i guess i am pretty good at stuff now after like 14 months
Nice 💪💪
You mean 127.0.0.0
127.0.0.1 is just localhost XD
How do I make it so that the player can't loose or gain hunger bars unless I set them
thx
but is there a simple way for me to make it so that they can't loose hunger
other than peaceful mode
schedule a repeating task that sets the players saturation every 20 ticks
Wil this work?
probably
k thix
that will only stop them losing health, not hunger
um, you are correct. I'm just tired
well it does niether
so what did I do wrong is the question
Registered?
Usually in your onEnable, yes
is it possible to grab a permission in prelogin?
no?
like that
getServer().getPluginManager().registerEvents(new StopHungerLoss(), this);
k thx
Spoonfeed
btw StopHungerLoss class needs to implement Listener
k thx again
you can listen to the PlayerLoginEvent
idk if that helps
kinda, i guess i could kick after they login
i just wanted to kick during the prelogin login process instead of after
that's the PlayerLoginEvent
i meant during prelogin sorry lol
when the player joins the server the PlayerJoinEvent is fired
@lunar moat Thanks It works!
@EventHandler
public void onPlayerLogin(PlayerLoginEvent e) {
Player p = e.getPlayer();
if (!p.hasPermission("luna.join")) {
p.kickPlayer("Not Allow lmao");
}
}
something like this?
yeah I think so
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerLoginEvent.html has a player entity, you can probably check permissions here
Usually when entering a portal, the portal searches for an area to create the portal. If it cannot find a safe space it creates the portal with four extra obsidian blocks at the bottom. Not sure if anyone has heard of this but it usually happens when you enter in ocean. When setting a portal location to a different world with e.setTo, (PlayerPortalEvent), and when in my case the portal cannot find a safe spot, it sets the location of the portal at y 246. Anyone know how I could make the y level for the portal the same as vanilla? (Nvrmind I fixed this with location.setY(50)
what am i doing wrong?
public final class BetaLogin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "BetaLogin Plugin Successfully Enabled");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "BetaLogin Plugin Successfully Disabled");
}
@EventHandler
public void onPlayerLogin(PlayerLoginEvent e) {
Player p = e.getPlayer();
if (!p.hasPermission("luna.join")) {
p.kickPlayer("Not Allow lmao");
}
}
}
its not kicking me when i join even though i dont have the permission
Are you op
nope
It might be that you’re listening too early in the login process
should i try at the playerJoinEvent?
Because at that time, many things might not have loaded yet. This would likely include kicking because it would reply on you being fully connected
Yeah give it a shot
But it might run when you switch worlds idk
am i able to then send a kick/error message?
it kinda worked, but then i got an Illegal PlayerChunkMap error in console
Hey ive got a basic problem i think if anyone can give me any advice
Delay it by a few ticks
im going to try the cancellation of event
?ask
Or you know, the disallow method in the login event
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
Like I said
This is why you check Javadocs
hey I literally just started trying to make a plugin for 1.8.9. I don't understand any of the @s or the different text files. does anyone have any tips to get started?
sorry if I sound crazy, I literally just started and have no idea how anything works.
Im talking about the things like @Override, etc
so annotations
yes
Override is a normal java annotation, you should learn the basis first
I guess what I'm trying to ask is where do I start
I love OOP...
There are hundreds of free tutorials for Java online, you should take a look there
Ok thank you guys!
I was trying to tackle the entire plugin thing first but I need to learn Java in order to begin. Thanks for the help, will do!
it works! thanks!
Anyone want to try and improve on this code?
https://paste.md-5.net/zequyawudu.java
And tell me what I can improve, to improve my java knowledge
well, you don't need the addEnchantmentLevels method
because you can simply use setEnchantmentLevel(getEnchamentLevel() + how many levels you want to add)
Well... what if I'm wanting to have that method for the sake of the code looking shorter/cleaner
yeah if you are repeating code it is not looking cleaner
I meant in other classes
it is basically the same method
setEnchantmentLevels(name, getEnchantmentLevel(name) + level);
//applyItem();
}```
How about that?
Better?
yes
anything else?
the same thing applies to the removeEnchantmentLevels method
but other than that your code looks fine imo
Aight
lmao
how do i get permission information from bungee lmao
I am trying to scan player inventory for a spicific item which is targetI Then I want to get the info of that item in the inventory. End goal is to check if there's a book and then get the meta and other stuff avbout the book. The code is mad at me for this
Any Ideas?
I know that it's an integer. god i'm bad at wording questions, I kind of meant what do I need to change to check all of the slots You don't have to answer, I know you've been helping a lot
All the stuff I can find on what I want to do is outdated
With your current loop you’ll need to get the item from getContents at that index
Or you can switch to an enhanced for loop and compare them directly
Also the basics of what you want to do aren’t outdated
ik but all questions on it are
Can I have a link to or an example of an enhaced loop
?
if u don't want to, just say so ik i've been asking A LOT today
thanks
I do this but it is mad at me. I'm sure i'm doing something wrong @young knoll
You access array elements with []
so .get contents [i]
but i tried that and it didn't work
@young knoll
i'm definently not picking up on something obvious
ItemStack diamond = new ItemStack(Material.DIAMOND);
Arrays.aslist(player.getInventory().getContents()).forEach(item ->{
//code
});```
or do the same thing but forloop
for(ItemStack item : player.getInventory.getContents()){
}
ok
thanks
not in a bad way
is there an easy faster one then stream?
use asList
thx for the help
ok thx
so they both do the same thing
but the for loop is simpler right?
either one will do what you want
This is probably still the best option, it avoids making a list
ye
yea i'm gonna do that
that way each time it loops you get a instance directly from the loop
Do I have to put targetI somewhere else? it's not detecting it (TargetI is the item that I want to look for)
for(ItemStack item : player.getInventory().getContents()){
//code here
}``` you don't need the current part
k
since you already have the ItemStack
eg
for(ItemStack item : player.getInventory().getContents()){
//code here
item.setType(Material.DIRT);
}```
How do i know if the item i'm looking for is what it found
sorry i'm being really slow
I only want it to trigger if it finds the item i want it to find
ok so in for loop ill do item.isSimmilar(TargetI)
if you want to stop the loop when it finds the target
just do if(isSimilar()){
return;
}
ok thanks
I want to get the variable invitemmeta out of this for loop. I tried delcaring it up above, and that didn't work
you don't need the second ItemMeta
You are trying to declare it again
I strongly suggest you get a good grasp on java basics before working with the API
^
K so like that?
and i'll look into that tmr
it's late
ok nvm
i got it
thanks ya'll
That if statement isn’t in use
since it implements Iterable u can just do for (ItemStack itemStack : player.getInventory())
What is the best way to serialize a BannerMeta (CraftMetaBanner) for storing in Redis? Bonus points if I can actually deserialize it
theres a serialize method that'll convert it to a <String, Object> map
to unserialize it, look at the constructor in CraftMetaBanner that takes a Map<String, Object> as the argument
Couldn't be bothered, I'm using Apache SerializationUtils.serialize and base64
how could i make it so spigot plugin outputs a message to online players in other servers connected with bungeecord?
How can I add those dependencies to maven? https://github.com/Wardenfar/Osm2Map/blob/master/build.gradle
I want to update that outdated project
What mappings does bukkit/spigot use?
Suggest adding a check if the item is null so you don't get NPE
Hey Guys,
maybe some of you can Help me with my Problem. My Problem is, when the InventoryClickEvent is called and I am in my custom Inventory he doesn't cancel the event when the Item is not an specif Item.
else if (event.getWhoClicked().getOpenInventory().getTitle().equalsIgnoreCase("Your Documents") && event.getInventory().getSize() == 18) {
if (event.getClickedInventory() == null) {
return;
}
if (event.getClick().equals(ClickType.NUMBER_KEY)) {
if (event.getHotbarButton() != -1) {
event.setCancelled(!isDocument(event.getCurrentItem()) && !isDocument(event.getCursor()));
}
}else {
event.setCancelled(!isDocument(event.getCurrentItem()) && !isDocument(event.getCursor()));
}
private boolean isDocument(ItemStack item) {
try {
if (item.getType().equals(Material.AIR) || item.getType().equals(Material.WRITABLE_BOOK) || item.getType().equals(Material.WRITTEN_BOOK) || (item.getType().equals(Material.PAPER) && item.hasItemMeta() && !item.getItemMeta().hasCustomModelData())) {
return true;
}
} catch (NullPointerException ignored) {
}
return false;
}
event.getClick() == ClickType.NUMBER_KEY - Enums can be compared with ==
Try that @abstract spindle
okay I will try
} catch (NullPointerException ignored) {
}
This is the stuff that leads to problems which will lead to days of search.
NEVER ignore a NPE like that. Handle your exceptions properly.
When you have a null pointer then look into your code and see where you messed up.
This is the equivalent of putting ear buds in when the fire alarm goes of...
and equals vs == doesnt matter when using enums. Internally its just == anyways.
Tbh instead of using a try catch I'd just check if the item is null
I use there, because it is necessary. The item what I get from the InventoryClickEvent can be null and other wise he can not handle it
Correct me if I'm wrong butI believe it avoids it entirely
Then make a proper null check
It is really important that you create variables here. You need to stop stacking methods. You should not just ignore the character limit.
Your code should be thin enough that you can read it on a small 4:3 screen.
Could you pls send the whole method? I can show you how to cleanly refactor this.
?paste
Ah yes switch-ify if statements
This is exactly your code just a bit refactored:
@EventHandler
public void onClick(final InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
Inventory openInv = event.getInventory();
InventoryView openView = event.getView();
String viewName = openView.getTitle();
if (event.getClickedInventory() == null) {
return;
}
if (viewName.equalsIgnoreCase("Your Documents") && openInv.getSize() == 18) {
event.setCancelled(!this.isDocument(event.getCurrentItem()) && !this.isDocument(event.getCursor()));
}
}
private boolean isDocument(ItemStack item) {
return item != null;
}
THX
Just used exactly that code and it worked without any problems.
Instead of serializing the GameMap try just adding a random String...
idk. I think 15?
Yes 15
That should not be the problem
It cant be
hi guys!,
i need help!:
how can i give my horse saddle or something like that
here is my code:
ItemStack sadel = new ItemStack(Material.SADDLE); // server sel
Entity horse = Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
horse.setCustomName(ChatColor.GREEN + "sosy 1 test 5566784sd AS DIM");
horse.setGlowing(true);
horse.setRotation(451, 16);
((Tameable) horse).setOwner(p);
```
Horse#getInventory#setSaddle
horse.getInventory().setSaddle(sadel)
cast horse to Horse not Entity
ItemStack sadel = new ItemStack(Material.SADDLE);
oops
Entity Horse = Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
Horse horse = (Horse) Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
like that?
yes
well more errors
ItemStack sadel = new ItemStack(Material.SADDLE); // server sel
Horse horse = (Horse) Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
horse.setCustomName(ChatColor.GREEN + "sosy 1 test 5566784sd AS DIM");
horse.setGlowing(true);
horse.setRotation(451, 16);
((Tameable) horse).setOwner(p);
horse.getInventory().setSaddle(sadel);```
try
Player p = (Player) sender;
ItemStack sadel = new ItemStack(Material.SADDLE); // server sel
Entity horse = Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
horse.setCustomName(ChatColor.GREEN + "sosy 1 test 5566784sd AS DIM");
horse.setGlowing(true);
horse.setRotation(451, 16);
((Tameable) horse).setOwner(p);
((Horse) horse).getInventory().setSaddle(sadel);
whats the error
Inconvertible types; cannot cast 'org.bukkit.entity.Entity' to 'me.fsih.horse.horse.Horse'
youre casting it to the wrong thing
replace Horse with org.bukkit.entity.Horse
((org.bukkit.entity.Horse) horse).getInventory().setSaddle(sadel);
ok no error so far let me test it
My class doesnt seem to get registered by the main class and I dont know why, this is the error.
Hello, I'm trying to make a Hypixel uhc plugin, but I keep getting this error and idrk how to fix it. Any help would be apprecieated
@quaint mantle Caused by: java.lang.ClassCastException: java.util.Collections$UnmodifiableRandomAccessList cannot be cast to org.bukkit.entity.Player
PlayerJoin.java:18
Yeaaaaah, tought I would get that one wrong
Player playersoundlist = (Player) Bukkit.getServer().getOnlinePlayers();
playersoundlist.playSound(p.getLocation(), Sound.ITEM_CHORUS_FRUIT_TELEPORT, 1f, 1f);
So what I did here was trying to make a list of online players to play a sound when a player joins
You need to iterate over each player
code
public class SwordListener implements Listener {
private UHC_Items plugin;
public SwordListener(UHC_Items plugin) {
this.plugin = plugin;
}
public void a(Player player) {
Bukkit.getScheduler().scheduleSyncDelayedTask(UHC_Items.getPlugin(UHC_Items.class)), new Runnable() {
@Override
public void run() {}};
for (int i = 0; i < player.getInventory().getSize(); ++i) {
ItemStack a = player.getInventory().getItem(i);
if (a == null) continue;
if (!a.hasItemMeta()) continue;
if (a == a) {
ItemMeta b = a.getItemMeta();
b.addEnchant(Enchantment.DAMAGE_ALL, 1, false);
a.setItemMeta(b);
}
}
}```
getOnlinePlayers() returns an array
You tryna schedule a delayed task?
yep
Idk why everyone keeps using scheduleSyncDelayedTask etc
Like the name is implausibly long
Use runTaskLater
It also returns a more useful object
public void teleport() {
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
List<Player> Players = new ArrayList<>(Bukkit.getOnlinePlayers());
public void run() {
for (int i = 0; i < Players.size(); i++) {
teleportplayer(Players.get(i));
}
teleport();
difficulty --;
};
}, 6000L);
}
For some reason, this code is not being called after 5min. Am I doing something wrong?
wait
Please use code blocks and format your code
Anyways if you wanna schedule a delayed task you’d do this
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//code that runs later
}, delayInTicks);```
class SwordListener implements Listener{
private final UHC_Items plugin;
public SwordListener(UHC_Items plugin) {
this.plugin = plugin;
this.plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onTick() {
Bukkit task = new (task)(this.plugin).runTaskLater(this.plugin 12000);
}```
something like this?
Jesus
thx
Ofc that won’t work
@quaint mantle java Bukkit.getOnlinePlayers().forEach( player -> player.playSound(player.getLocation(), Sound.ITEM_CHORUS_FRUIT_TELEPORT, 1f, 1f) );
yea.. I know abit of java
Let me give you a spoon

Is there any way around this cancer?
public static BannerMeta getMeta(String key, String field) {
String configSerialized = jedis.hget(key, field);
YamlConfiguration config = new YamlConfiguration();
try {
config.loadFromString(configSerialized);
} catch (InvalidConfigurationException e) {
return null;
}
return (BannerMeta) config.get("meta");
}
public static void setMeta(String key, String field, BannerMeta meta) {
YamlConfiguration config = new YamlConfiguration();
config.set("meta", meta);
jedis.hset(key, field, config.saveToString());
}
ty
void method() {
BukkitTask task = Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
//code to execute later
},12_000L);
}```
@hollow sand
What do you define as cancer?
Indeed
thx ill try that 🙂
Using YamlConfiguration.saveAsString() as a bootleg serialization method
Lol why do you load and save as/to string?
You put the entire config in your redis cache?
There's got to be a better way to do this, right? I'm thinking DI might be beneficial. If it's the best way to go, then I'll switch from an interface to an abstract class.
I'm using YamlConfiguration.saveAsString() because it looks like the easiest way of serializing a bukkit object to put in redis
Oh well, I’d use Gson for serialization but that looks fine jolly?
You can always serialize bukkit objects as Strings using BukkitObjectOutputStreams if you dont mind using nms.
Creepercry hmm yeah dependency injection might be a good way to loosely couple your code
Yeah what I was previously doing was having a single static instance that I can retrieve and do stuff that way but DI seems better
Is this code correct?
player.teleport(0, 67, 18, builderspawn);
You need to wrap that into a location object
world, x, y, z iirc
Yea I tought it wasnt
yeah that
iirc??
is builderspawn already a location?
yes
if I recall correctly
World builderspawn = Bukkit.getWorld("builderspawn");
Player#teleport(Location)
try Location builderspawn = Bukkit.getWorld("builderspawn").getSpawnLocation();
k
Location builderspawn = Bukkit.getWorld("builderspawn").getSpawnLocation();
p.teleport(builderspawn);
Should be correct now
since there already is getSpawnLocation, I dont need to put coordinates
So long as you have a world called builderspawn
Rename your variable from p to player pls.
Prevent single character variables
Ok, I'll keep that in mind
Thx for help.
Hey, i did this but for some reason it still didn't work 😦
Code:
public void teleport() {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
List<Player> Players = new ArrayList<>(Bukkit.getOnlinePlayers());
for (int i = 0; i < Players.size(); i++) {
teleportplayer(Players.get(i));
}
teleport();
difficulty --;
}, 6000L);
}
please use code blocks or paste site
Do you even call the method "teleport()" in any of your classes
Looks like recursion abuse
https://www.spigotmc.org/threads/serialization-with-objectoutputstream-objectinputstream.398629/
Lol the forum post asking how to use BukkitObjectOutputStreams just tells me to use YamlConfiguration
okay why tf
are you wrapping Bukkit#getOnlinePlayers
and why are we not using
for (Player player : Bukkit.getOnlinePlayers()) {}
oof my dumb brain forgot that lmao
please camelCase your variable names, not PascalCase as well
Also why are you repeatedly scheduling delayed tasks instead of using a repeating one
you have a 5 minute delay on that task, and it calls itself
I want to check if a player is in a certain world, am I doing it correctly?
if(player.getWorld().equals("builderspawn")){
}
ty
if(player.getWorld().getName().equalsIgnoreCase("builderspawn"))
I guess its correct now
Is there like an event for building or destroying blocks and stuff?
Is it possible to run mods + plugins with a fabric server
Yes there is
is it the same as BlockPlace event?
ty
No problem
Less goo
only forge and plugins
rip
My friend used to run a modpack server with a bunch of plugins so I guess yeah u probably can.
as i said, only forge and plugins, magma has yet to add fabric support
Hm okay
There isnt getworld for BlockPlaceEvent?
k
ty
Oh this is cool, I'm learning without watching any tutorials
well you should do that
Probably
or read documentation
Altough, as long as I learn and progress, I think I'm fine.
tutorials are good so you know what things do without needing to ask here
After this plugin I really should get back to those tutorials, it seemed like a good idea to really use the stuff I learned before moving on with another knowledge
wdym?
eg, tutorials go over the basics like events, what they do how to register them
it saves time asking here
not telling you to watch them
just saying in general
Yea I already did that a while ago but u need to USE them before learning other stuff
Maybe its the main world that you have in your server.properties
Nah I found out they still are in MultiWorld config
So the server creates them on startup
Anyways, do you guys obfuscate your plugins?
no
lol
Cant the source code be revealed then?
wait why do you wanna ob?
The only real point in obfuscation is to protect intellectual property
I dont, but I seem interested in how it works
it can still be decompiled and read
just makes it slightly more annoying
And reading stack traces costs you 10 times as much time
Sheit so it just makes the plugin like 10 times slower
But for a commercial product obfuscation is enough to say you made an attempt to protect your property when it comes to court cases
why would you
So u think obfuscation is useless as long as the plugin isnt commercial
totally
if anything some people find it sketchy for free plugins to be obfuscated
theres just no point for free plugins
Oh yea, so there isnt a backdoor
open source is nice because then there's a lot more trust in it
Id never obfuscate my plugin unless its a premium one. And then its still just a consideration.
^
it just makes it absolute hell if the project is big enough
The only reason MC is obfuscated is for legal reasons. They have to make a basic attempt at protecting their IP/trademark.
legit look at NMS, it's obfuscated but we still use it
Anyways: update, I got thies error when I try to connect to my server, I have NO IDEA whats going on here.
[13:52:59 WARN]: Failed to handle packet for /xxxx
java.lang.IllegalArgumentException: Listener already listening
at net.minecraft.server.v1_12_R1.Container.addSlotListener(Container.java:56) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.EntityPlayer.syncInventory(EntityPlayer.java:236) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:219) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:233) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:140) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:845) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [server.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
[13:52:59 INFO]: Limejboi lost connection: Internal server error
[13:52:59 INFO]: Limejboi left the game
?paste
you are registering a listener when it is already registered?
No, It's caused by my plugin
huh
?paste
send main class too
public final class main extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
getCommand("menu").setExecutor(new menu());
getCommand("mapdone").setExecutor(new mapsdone(this));
getCommand("spawn").setExecutor(new spawn());
getServer().getPluginManager().registerEvents(new clickevent(this), this);
getServer().getPluginManager().registerEvents(new PlayerJoin(), this);
getConfig().options().copyDefaults();
saveDefaultConfig();
}
}
use paste
you should really learn some java, or java best practices before heading into spigot
^
yeah i agree with otDan
Please do
this code is small
I need to finish this project, I'm almost done with it.
also you don't need getConfig().options().copyDefaults();
if you dont know java you cant use apis
saveDefaultConfig(); does everything you need
Some learn best with tutorials, some learn better by trying and failing.
Yea, but I need to finish this lil plugin right here
I'm like 80% done now, so I wanna finish it.
youre like doing it for server?
wat abt both 😏
Yes
Astreans? ig
Yea
U know it?
yea
Where are u from bro?
so youre like cz
Yup
czechia too
Nazdaaar 😄
cssssssssssss
chceš pomoct v DM?
jj klido
pognt
england
dude
wtf
lowercase class name
and the name main
i thought i already told you not to do that
Any ideas why this produces an NullPointerException? The error: [15:49:04 INFO]: Enabling MyWorlds v1.0-SNAPSHOT [15:49:04 ERROR]: Error occurred while enabling MyWorlds v1.0-SNAPSHOT (Is it up to date?) java.lang.NullPointerException: null at com.irgendwer.myworlds.MyWorlds.onEnable(MyWorlds.kt:11) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:177) ~[JavaPlugin.class:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:318) [JavaPluginLoader.class:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:399) [SimplePluginManager.class:?] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:477) [CraftServer.class:?] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:418) [CraftServer.class:?] at net.minecraft.server.MinecraftServer.func_71247_a(MinecraftServer.java:389) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:316) [nz.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:596) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
The Code: ```
class simplecmd: CommandExecutor {
override fun onCommand(
sender: CommandSender?,
command: Command?,
label: String?,
args: Array<out String>?
): Boolean {
if (sender is Player) {
val player: Player = sender as Player
val sand: ItemStack = ItemStack(2)
sand.setAmount(20)
player.getInventory().addItem(sand)
}
return true
}
}Main class:
class MyWorlds: JavaPlugin(), Listener, CommandExecutor {
override fun onEnable() {
this.getCommand("test").setExecutor(simplecmd())
}
override fun onDisable() {
}
}``` (Written in Kotlin)
Is command in plugin yml
MyWorlds.kt:11
imagine using kotlin
Kotlin looks like someone saw Java once, 10 years ago and wrote down what they could remember.
@sleek pond using Kotlin is perfectly fine
still compiles to byte code that is no different then what java does itself
Be nice if people stopped actually caring about the language someone is using especially if it isn't even remotely relevant given the problem occurring -.-
its a joke -_-
Nothing wrong with commenting on an observation
Don’t you still need to shade Kotlin for the plugin to work
No
the Kotlin compiler will turn Kotlin code into appropriate standard JVM Bytecode
meaning you can use a Kotlin JVM for it or Java JVM and it wouldn't matter
Why does Forgelin exist then
don't know what it is, do you mean running Kotlin JVM Bytecode on Java JVM Bytecode?
why does forge gradle exist
It ships the Kotlin Libraries that it gives out proper error messages and not points to a not existing .java file
Ah
Hi, does someone knows if there is a maven repository of MMOItems ?
aaaaaaaaaaanyways, yes that was it ty
MMOItems isn't opensource so why would you expect them to have a repo for it that is publicly accessible @opal sluice ?
At least to get the API ^^'
probably should bug them to release an API lib then
instead of forcing the developers to buy the plugin that they are not using other then for development purposes
Yeah, I'll write them to ask for it since it's a bit annoying to ask the customer for it's copy of the plugin to actually dev on it ^^'
Yep probably wise. Never makes sense to have a premium plugin that has an API, but restrict the developers from actually obtaining said API lol
so as long as that is the case, not many people will develop additional resources for a premium plugin since you know the barring to entry for it legally.
Yeah, I guess that's why the most of the integration of this plugin is in other "Mythic" line up plugin
https://paste.md-5.net/etuhaqasip.java
[15:07:14 WARN]: org.apache.commons.lang.UnhandledException: Plugin Arma v1.0 generated an exception while executing task 80
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
at java.util.ArrayList$Itr.next(ArrayList.java:861)
at vinnydgf.arma.Arma.tick(Arma.java:29)
at vinnydgf.arma.Arma$1.run(Arma.java:55)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
... 3 more```
Arma.java:29
Main class https://paste.md-5.net/okudusabiq.java
concurrent modification. you are adding/removing from an array Async
Arma class ^
clone the array that you're looping through instead
thats what I do
wait
wrong thing
where you mean ?
@fading lake easier way is toss the synchronized tag on it
wait you can do that?
Yep
you mean the synchronized keyword? I'd love to know how that works o_o
mm
yes talking about the keyword
using that keyword makes the method synchronized in that it forces anything using to wait in line
oh thats useful, I've never seen it used before lol
all threads have to syncronize on that object when they access it
Not something you should toss everywhere, but still handy in some cases like dealing with an Array for example 😛
synchronize forces them to take turns in accessing
wait does that mean if you call something async then it calls a synchronized method, then it waits for the synchronized method to finish before continuing with the async method?
yes
🤔
Alternatively you could also use volatile keyword too @fading lake
wait what does that one do, apologies not seen these used before
@quaint mantle blockbench
volatile forces cloned objects to merge with the master @fading lake so that everything has the same state for an object 😉
so if an object is allowed to be used Asynchronously, you can put that asynch object into a method where anything else accessing said method async will merge their copy of the object with the master, that is where the object originated from.
Thus, even if its async the object state is maintained regardless who has a copy using that method
where exactily
line 29 of Arma
what is happening is you are accessing the array for reading at the same time you are removing
line 55 is running Async tick()
this error ?
that is calling your remove
i never went to use async
@fading lake quite the opposite
then run it sync not Async
add this would solve the error?
https://gyazo.com/30d6304c43505e5529c15159012f2528 its being ran async
you could replace runTaskTimerAsynchronously with runTaskTimer
ok
How do I disable that Spawn get's generated on load of a world?
The volatile modifier is used to let the JVM know that a thread accessing the variable must always merge its own private copy of the variable with the master copy in the memory. Accessing a volatile variable synchronizes all the cached copied of the variables in the main memory.
Has its uses, but just like synchronized not something to just toss everywhere as well 😛
ah okay
@fading lake always nice to randomly gain some insight on using something that is rather easy thing. IE using synchronized keyword on an array to stop CME's instead of changing the entire method XD
Yea im still on the same project. Ill start doing Highercase on my other plugin
any way?
set a different spawn
oh wait I think I understand now, so imagine a class like this
public boolean a = true;
}
if I had 2 different runnables doing stuff with it, and one of them changed it's value, the other thread wouldn't notice it normally. Would the volatile keyword make both threads cache a live/updated result of when the volatile variable changes?
I want to disable it entirely since it generates too much lag
I'm not sure that is possible unless you use NMS
^
unless you want to fiddle about with it in protocollib, there's not easy way
find out how multiverse does it?
You can try that too
I mean you could immediately unload the chunks in the world on creation but at the end of the day, they're still cached
This is the error I get, I connect my menu opens, join messages are sent without issue, however it disconnects me 2 seconds later and I get this error
[16:29:23 WARN]: Failed to handle packet for /xxx
java.lang.IllegalArgumentException: Listener already listening
at net.minecraft.server.v1_12_R1.Container.addSlotListener(Container.java:56) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.EntityPlayer.syncInventory(EntityPlayer.java:236) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:219) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:233) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:140) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:845) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_212]
[16:29:25 INFO]: Limejboi lost connection: Internal server error
?paste
This is my code.
https://paste.md-5.net/jolunebuno.java
do you register the listener multiple times?
@quaint mantle what happens when /menu is executed? (it's code)
I have getServer().getPluginManager().registerEvents(new PlayerJoin(), this);
in my main class
?paste
Not randomly
If all strong references are lost then it’s going to be queued for clearing
And cleared
like how long food lasts
you know steak gives you big saturation
takes a while before your hunger starts falling
but something like potatoes
have small saturation so your hunger falls earlier
wait for real?
do you have ANY areas where anything touches the playerlist?
6 yeras playing minecraft i have not once heard about saturation lmao
Well I mean let’s say you create new WeakReference(new Boolean(true)); this would instantly be cleared as you never put a strong reference to that boxed boolean object passed. But if you’d do smtng like:
class a extends JavaPlugin {
Boolean b = new Boolean(true);
void onEnable() {
Reference<?> ref = new WeakReference(b);
}
}``` here we have a strong reference to that object. If and only if all strong references are lost/unset then and only then would the weak reference stop referencing that object
yeah, search it up
I dont think so.
Idk if I explained it better
anything that touches custom crafting recipes?
No
its something to do with when the menu adds a listener to the slot, its just that error isnt making too much sense to me
(NMS not spigot)
Me neither
Ive read volatile? Who is doing threading? Volatile fixes only very specific issues.
oh I was just wondering what it is dw
His issue is fixed. he was using Async when he didn;t need to
Alright
are you accidentally launching the menu twice?
yes exactly
oh, thank you ❤️
Nope
huh
thats really weird
copy/paste your code somewhere, and slowly remove bits of it until it stops crashing, once it stops crashing, you know what bit was causing it ig
[09:51:36 WARN]: org.apache.commons.lang.UnhandledException: Plugin Arma v1.0 generated an exception while executing task 279
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
at java.util.ArrayList$Itr.next(ArrayList.java:861)
at vinnydgf.arma.Arma.tick(Arma.java:29)
at vinnydgf.arma.Arma$1.run(Arma.java:55)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
... 3 more
line 29
public synchronized void removeArrow(Arrow a) {
arrows.remove(a);
}```
line 55 is call async
Not quite. The caches dont receive an update to the variable but rather flush their result directly instead of caching it.
In the class "Arma", line 29 and and 55, there is something to do with an array-list
@quaint mantle Your issue is probably due to you trying to make the player issue a command before the Join event has finished. Instead of using p.performCommand make a reference to your menu command in your plugin and call it directly.
public void onEnable() {
getServer().getPluginManager().registerEvents(new GunEvent(), this);
sendMessage("§aHabilitado com sucesso");
new BukkitRunnable() {
@Override
public void run() {
tick();
}
}.runTaskTimer(this, 0, 1);
}```
You are modifying a collection while iterating over it.
Probably
he is
clone the collection if possible
asynchronous understanding complex
he's removing in teh tick() method but also adding from other events
sorry, wdym by 'flush'
wait let me see if i understand
public void tick() {
for (Arrow a : arrows) {
if (a.isDead() || a == null) {
arrows.remove(a);
} else {
if (a.hasMetadata("sniper")) {
particle(EnumParticle.CRIT_MAGIC, a.getLocation()); return;
} else if (a.hasMetadata("comum")) {
particle(EnumParticle.CRIT, a.getLocation());
}
}
}
}```
i need do this inside of `public void run() {` ?
flush their result directly to the L3 cache or directly to the memory
oh thanks
use an iterator not a for loop
his for loop does
yea
3 ways of doing this:
- Use an iterator and its remove() method
- Create a second empty collection. Then while iterating over the original you add all elements that should be removed to this extra collection.
After iterating you simply remove all elements that are in the new collection. - Use the removeIf() method
ok
One spoon:
public void tick() {
final Iterator<Arrow> iterator = this.arrows.iterator();
while (iterator.hasNext()) {
final Arrow arrow = iterator.next();
if (arrow == null || arrow.isDead()) {
iterator.remove();
} else {
if (arrow.hasMetadata("sniper")) {
particle(EnumParticle.CRIT_MAGIC, arrow.getLocation());
return;
} else if (arrow.hasMetadata("comum")) {
particle(EnumParticle.CRIT, arrow.getLocation());
}
}
}
}
What type of collection do you use?
you don't cast if you specify the generic arguments the first place
Because the best collection for removing while iterating is LinkedList.
Thats also the only thing a LinkedList is good at. Otherwise its trash.
i still don't know what collection is
do you refer to the style of the code?
hes just talking in general
the data structure you are using
like are you using a Set, List
so, to get an entity I usually use metadata
@minor garnet Collection is a term to refer to things like arrays or hashmaps. Easier to refer them that way because there is quite a bit of them, and they well collect stuff and sometimes collect other collections etc etc.
Ur probably not here but I did do that if the item isn't null it doesn't return the item maybe i'm missing something, but in my case the player will pretty much always have the item.
Iterable is the base interface
Collection inherits from Iterable
The base collections (List, Set, Queue) inherit from Collection
Then each base collection has specific implementations
List > LinkedList, ArrayList etc
Set > HashSet, TreeSet etc
so when he asked me that question he was referring to that
private ArrayList<Arrow> arrows = new ArrayList<>(); ?
generally bad practive to return nulls @deft sedge second you are not checking if the item is null rather its metadata. Which will result in an NPE in itself if the item is null to begin.
ok so you're talking about daughter class and mother class
essentially yes
ok
what would I return if it didn't find anything bc I think I can only return ItemMeta
change the methods type in this case
if yoru return type ItemMeta and you have nothign to return, then return null and check if its null in yoru calling method
But you can return an empty Itemmeta though @deft sedge
I think returning null is still viable.
Alternative would be returning an Optional<ItemMeta>
This is more elegant when you are using functional interfaces and the stream API
k thx guys
Avoid returning null whenever possible
makes it easier when you have other code logic relying on the method and if there is problems down the chain, makes it quite clear or more clear where that problem is at and why.
@deft sedge depends how exactly you are doing it. The way you have it in your code, that object only persists so as long as the code in that method is running, but all those objects disappear once you return it like you are.
Yes, I resolved it now and you are correct.
i still get the error
@lost matrix is this the documentation on the optional thing
?paste
hi im hella new to mysql and i don't know anything it really or how it works do anyone recommend me any tutorial or a wiki or something to understand how it's commands work in general?
ggl
GunEvent.java:74 NPE
dude i litera do this
and when i export this project for plugin thats comments work, i dont know why
what is line 74?
nope, notnull
how do u do that
using decompiler
its a new update of discord, only send a message passing the digit limit
i found the problem -_-
it was?
Would this not stop player damage?
because it doesn't work
i have it declared and everything
thats Item Damage., When an item takes damage
but I still have a problem that I thought had to do with the async but it's actually when it comes to defining the particle for a projectile
ok
I kinda thought that
is there a way for me to limit just playewr damage
because the only one i can find is entity damage
and i dont' want to stop everything from taking damage, just players
How are your projectiles handled?
i think its because a api im using dont delete a projectile
and get on other location and teleport it again, i dont know
Just add a custom model data id to the ItemStacks meta. Then change the appearance of that item using the model id as predicate in your resourcepack.
So you are using arrows?
yes
How do if an entity damage event was a player?
Minecraft has some really weird limitations for the velocity of entity projectiles.
For high velocity objects like bullets i would always use a ray casting approach.
its true,
Player extends LivingEntity which extends Entity.
So you can just get the damaged Entity from the event and check if its an instanceof Player.
if (i.contains("Mauser")) {
setMetadata(e.getEntity(), "sniper", "sniper");
} else if (i.contains("Otherthing")) {
setMetadata(e.getEntity(), "comum", "comum");
} else if (i.contains("Balblalbla")) {```
its better use switch here ?
would be better I think
This looks like a job for a Map
how to generate a line of particles using the vector?
Are u using datapacks?
no -.-
?jd
package index
just fyi, the javadocs has a search bar
upper right
you could try searching vector and seeing everything that uses vector
how to create like message manager that would pull message from messages.yml?
Create a class with some fields in it. Load a messages.yml using the YamlConfiguration class. Read all messages and add them to an instance of your messages class.
Just created a little implementation for bullets where each bullet has different trails, impact mechanics and is affected by gravity based on the bullets mass in grams.
im using 1.8
but i need a code like this,
public void drawLine(Location l, Vector dir) {
for (double i = 0; i < 200 ; i += 0.5) {
dir.multiply(i);
l.add(dir);
Arma.getInstance().particle(EnumParticle.CRIT_MAGIC, l);
l.subtract(dir);
dir.normalize();
}
}
@EventHandler
public void projectileLaunch(ProjectileLaunchEvent e) {
Projectile pt = e.getEntity();
Player p = (Player) pt.getShooter();
String i = p.getItemInHand().getItemMeta().getDisplayName();
Arma.getInstance().particle(EnumParticle.FLAME, p.getEyeLocation());
invisibleProjectile((Entity) pt);
drawLine(pt.getLocation(), p.getLocation().getDirection());
sound(p, i);
}``` funny drawLine is dont working
- Ancient version.
- Wrote this. Didnt test:
public void particleTrail(final Location from, final Location to, final Particle particle, final double spacing) {
final Location currentLocation = from.clone();
final Vector direction = to.toVector().subtract(from.toVector());
final Vector steVector = direction.normalize().multiply(spacing);
final int steps = (int) (direction.length() / spacing);
final World world = currentLocation.getWorld();
for (int i = 0; i < steps; i++) {
world.spawnParticle(particle, currentLocation, 1, 0, 0, 0);
currentLocation.add(steVector);
}
}
Just add the direction to the current location.
you mean player.getLocation().getDirection() or projectile.getLocation().getDirection() ? and i need cast it ?
what
but answering my question to get the final location would I have to take the direction of the player or the projectile?
why
Bukkit.getServer().getTPS()
getTPS doesn't exist for me but for others it does
MinecraftServer.getServer().recentTps
like your illustration, demonstrates quite a few different things in just one 🙂
is there a way to do recipie.setIngredients('T' , Material.CUSTOMITEM)
instead of the normal materials
can i check the name of the material?
would this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/PrepareItemCraftEvent.html work?
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
Guys, any Idea why this always will use the default world generator? ```
class simplecmd: CommandExecutor {
override fun onCommand(
sender: CommandSender?,
command: Command?,
label: String?,
args: Array<out String>?
): Boolean {
val create: WorldCreator = WorldCreator("test")
create.generator("FLAT")
create.createWorld()
return true
}
}```
the default world generator, also Default
this I mean
Try this Bukkit.createWorld(new WorldCreator("name").type(WorldType.FLAT));
That's in java, but in kotlin it would be
Bukkit.createWorld(WorldCreator("name").type(WorldType.FLAT));
i think
And also what brings you to Spigot plugin development 😄
I just use this discord as a break from King Mammoth lol
MinecraftServer doesn't exist for me