#help-development
1 messages · Page 1670 of 1
I didn't notice that I wrote EconomyManager.setupEconomy (); in the wrong place
and no i dont want > 1
public void onEnable() {
instance = this;
Bukkit.getPluginManager().registerEvents(new BubleUse(), this);
Bukkit.getPluginManager().registerEvents(new GUI(), this);
Bukkit.getPluginManager().registerEvents(new ItemUtil(), this);
EconomyManager.setupEconomy();
File config = new File(getDataFolder() + File.separator + "config.yml");
if (!config.exists()) {
getConfig().options().copyDefaults(true);
saveDefaultConfig();
}
}
if (!config.exists()) {
getConfig().options().copyDefaults(true);
saveDefaultConfig();
Listener[] omg
yes. thanks
Ok np
thank you very much for your help
okay, thanks
if your fly command doesn't accept any extra arguments, then you should be able to safely discard the extras
also, where is 'p' coming from?
ofc it can
well it depends on if the variable is set after initialization
final doesn't make a set immutable so it should be fine?>
some people do that to clear a collection as opposed to .clear()
which can be faster sometimes
anyway I have no idea what suggestions you're looking for
but off the top of my head you could condense it into this
private HashMap<UUID, Boolean> flyingPlayers = new HashMap<>();
protected boolean execute(CommandSender sender, String[] args) {
Player target;
// you could do this in one line but for the sake of readability i'll do it this way
if (args.length >= 1)
target = Bukkit.getPlayer(args[0]);
else if (sender instanceof Player)
target = (Player) sender;
if (target != null)
flyingPlayers.put(target.getUniqueId(), flyingPlayers.containsKey(target.getUniqueId()) ? !flyingPlayers.get(target.getUniqueId()) : true);
return true;
}```
i changed the method because i have no idea where you're getting 'p' from
you shouldn't be generating a new instance of a command every time a player uses it, if that's what you're doing
indeed
p is the player
imagine one letter variables
but where are you getting that? because it's not an argument in your method
wdym?
Where's p coming from?
What's the parent class?
abstract command
...are you setting p every time a player executes a command?
so p is a class level variable?
he probably uses something like this
public abstract class TargettedCommand extends SimpleSubCommand
{
protected TargettedCommand(SimpleCommandGroup parent, String sublabel) {
super(parent, sublabel);
}
@Override
protected void onCommand() {
final Player player = findPlayer(args[0]);
onTargettedCommand(player);
}
protected abstract void onTargettedCommand(Player target);
}
his execute method only accepts arguments and the command class has a class-level variable called 'p', from what I can gather
?paste
so you are in fact setting p every time a command is executed
can you see why this would cause problems?
no
its generally not really encouraged to cache a player object either
^ mutable
which is why it would cause problems
instead of doing that, just pass the relevant player in through execute
:/
it's not a massive change to make to your existing class
How do I connect my plugin to discord webhook and log events with it?
why would i pass the player every time if i can get him from there
just add a CommandSender parameter to execute and pass that in through your onCommand method instead
i know but why
because you're not caching and operating on a reference to a mutable object that way
I suggest using a discord wrapper library
such as JDA or Javacord or Discord4j
gimme sec
implementing low level logic to handle discord api is gonna take you quite the effort
so just use a library for it 😄
not 100% certain how spigot's server thread works but there's a risk of running into situations where that player object changes and messes up the results of a command execution
Alright got any good tutorials for it?
jordan osterberg
there's lots on the internet, find one and send it here and I'll review
this. i hate java culture ("how do I do [simple task]?" -> "import [massive library]"), but this is a valid use of "import library"
are we talking about mutating the player map or just the player object?
yeah lol
for context, we're discussing his command class, whereby each command caches a reference to the player that last used it and uses that to execute the command
this
https://youtu.be/LPaW1Xw_wUs what about this one?
Let me teach you how to Sync your Discord and Minecraft server using the JDA open source library! I actually use this on a few different SMPs I host for friends, and it's super helpful and fun :]
pom.xml: https://gist.github.com/JordanOsterberg/f046bbd7c5adfd822b930e2201fa72be
config.yml: https://gist.github.com/JordanOsterberg/b33f79f5460582ce...
that ones probably fine
lmao i just copied the link
whereas i'm saying that you should only be passing through command senders as parameters rather than caching them
O
esp since player is mutable
yeah well its not a great design
i dunno what caching is
but a player instance is valid during its entire online session
hanging onto a reference for later use
that is login all the way to disconnect
What's a good auction plugin?
it'll more or less work, but there's pretty much no need for it
storing things for later use
and again depending on threading/etc. there can be issues
yeah
because if your object changes in the course of command processing, it will produce undesired results
also a reason to never use mutable keys in a map
ah yea but i'm storing the player no?
well the majority of bukkit api isnt thread safe and is made for the server thread merely
that's what I was afraid of
yea maybe changing the value on every command but yea
ye
basically, code with the assumption that everything can and will break
murphy's law lmao
nothing will break here :/
also good practice to follow best practices just to keep yourself sharp (^:
i hate java
LMAO
it was my first language but C# is just so much better
yeah its great except its unorthodox choices of cases
Java's main thing is being cross platform
At what point can plugins no longer be added to the plugins folder to be detected for that session? If a plugin that loads on STARTUP adds a plugin will it be detected that session?
i only use C# for visual parts
probably
i mostly use C# for game dev, since Unity/MonoGame (or XNA depending on your age), but writing desktop applications for Windows with it is piss easy
isnt startup like ultra early
I deliberately chose it for some accessibility software I wrote because I knew the friends I originally wrote it for would be happy to just have an .exe that runs out of the gate
It is but the fact that It is loading plugins indicates that it may have already "locked in" teh plugin list
ie ->
Gets all plugins
loads the ones @ STARTUP
does the other shit
loads the ones @ POSTWORLD
final stuff
okay before I go, I'll drop my original question here again:
how inefficient would it be to forgo using NMS pathfinding in favor of writing my own (version-independent) code? the implementation isn't the issue, I'm just wondering if having a thread running to manage entity AI and pathfinding would cause any sort of massive overhead compared to the development overhead + pain in the ass factor of using NMS.
and a plugin added at Startup may not be detected
hmm - this may be a question for the paper folk
tl;dr I'm writing an AI system that people can extend with their own custom coded modules and script onto entities mythicmobs-style and NMS is just cursed
public static void updateLevel(Player p) {
Bukkit.getOnlinePlayers().forEach(all -> {
Scoreboard scoreboard = all.getScoreboard();
Objective obj;
if(scoreboard.getObjective(p.getName()) == null) {
obj = scoreboard.registerNewObjective(p.getName(), "dummy");
} else {
obj = scoreboard.getObjective(p.getName());
}
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
Score score = obj.getScore(p.getName());
NitUser user = new NitUser(p.getUniqueId().toString());
XYSection section = (XYSection) user.getSection(new XYSection(p));
obj.setDisplayName("§7→ §bLevel §7| §f" + section.getMana() + "§7 → §bMana");
score.setScore(section.getLevel());
all.setScoreboard(scoreboard);
});
}
Hello, I would like to set the mana and level as the BELOW_NAME of each player. Unfortunately i have the problem that it is set correctly for one player, but the same mana number is set for the next two as for the 1st set and the levels are then 0
Hey, is there any documentation for how one should implement SpecialSource in their build process?
I'm looking at specialsource-maven-plugin, and the only example of its usage is this forum post
Nevermind! I scrolled up and found out that the 1.17 release thread had info
^v^
will that code shoot fireball in the direction player is facing when he will press on mousebutton or did I something wrong?
Action ac = click.getAction();
if(ac == Action.RIGHT_CLICK_AIR) {
if(player.getItemInHand().getType() == Material.FIRE_CHARGE) {
player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.FIREBALL);
Fireball ball = player.launchProjectile(Fireball.class);
ball.setVelocity(player.getLocation().getDirection().multiply(2));
player.sendMessage("fireball was launched");
}
}
}```
have you tried?
no, I'm just asking if code is written good before I export anything
That will spawn 2 fireballs
yeah but is that code written well if u ignore player.getItemInHand because it is deprecated
you only use ac once so don;t make a variable for it
don't make throwaway variables if they're not for readability sake
that's what I follow, Idk if it's good practice though
so question if u use cos for x , sin for y what do u use with z ?
if (click.getAction() != Action.RIGHT_CLICK_AIR) return;
cos to ?
o
ok so I don't need to make Action variable I can just use that
delete teh spawnEntity line, as you are launching a projectile
lol forgot to delete it thanks
looping through the inventory slots is the only way iirc
wait
declaration: package: org.bukkit.inventory, interface: Inventory
this is hwo to check i guess
o
getContents()
check for the values of getContents()
or u know
just go with the usual way, checkign for slots
declaration: package: org.bukkit.inventory, interface: Inventory
do some logic with this
hey i have ```if (clickedEntity instanceof Player) {
if(player.hasPermission("illegal")) {
if (kelepce.isSimilar(player.getInventory().getItemInMainHand()));
((Player) clickedEntity).setWalkSpeed(0);
player.openInventory(((Player) clickedEntity).getInventory());
}``` this method i want to see someone others inventory by clicking them and the method setwalkspeed still working when im closing the inventory, how can i provide walk speed default after closing the inventory.
Can anyone help?
Instead if passing the player as an argument just loop over all the players ans use the player object to get his mana and lvl instead of the player you passed as an argument.
If you really want to make an updatPlayerLvl then only update the scoreboard of that player 😉
Hey @ivory sleet I tried implementing webhook system and everything is working good so far but I got an issue where I cant include \n when setting description of an embed. Any ideas on how to fix it?
what happens when you include \n?
hey what to do If I made two plugins that depend on each other?
design better
It throws this in console: [Ljava.lang.StackTraceElement;@b584a7
expected that answe
did you escape it?
wdym?
double \
lemme try
like a dependency?
It worked @eternal oxide, thanks
yes
can either work without the other, or are they really a depend on both
Put them both as depending on each other and make them not reference each other in onEnable and you should be good
just tell your plugin its a dependency and say what plugin it should be. Then disable it when it cant detect the plugin. If you add it as a dependency it will load the plugin as one of the last ones. after that you can ask for a list of the plugin and print an error and unload the plugin
asking for the third time
Help, the event "AsyncChatEvent" isnt call, because i use bungeechat. Do you have any idea to fix that ?
``` what does that mean?
linking errors because you have two plugins providing the same class
Listen on your proxy.
You probably shaded one plugin in and also installed it. Or you have two different plugins providing the same class.
Trying to prevent the unloading of a world with a chunk ticket sounds hacky.
I have another plugin that uses the same plugin as an API
I need to keep a chunk loaded for sth, but the chunk ofc wont stay loaded if the world itself gets unloaded
shade -> relocate
so what do I do?
can I shade without maven?
Shure. Gradle shadow plugin if you are more into gradle.
If you manually just throw in your jars then you are out of luck.
can i do it in pom.xml?
2 questions. What's the best plugin for taking your custom models and import them in the game?
and if I were to make my own model maker from scratch, how would I do that/
unlikely cos I have no weird plugins on my test server and no warning or whatever in the logs
F
fam there was an exception thrown by my plugin in an event listener that caused the server to disable
but the weirdest thing is that it was only visible in logs once I disabled debug in spigot.yml
any decent way to use the #applyBonemeal(blockface)? I've seen reflection;NMS stuff, but I don't know if there's other ways?
How do I access WebhookURL?
get the webhooklink from your server
path should be there
but, yea should be
wait no
https://discord.com/api/webhooks/
on your webhook that you set-up for your server, there should be Copy Link
You just want to get this String from your yml?
Because the path is DiscordWebhook.WebhookURL
Yes I wanted that, thanks!
is there a standard database that most developers use? For storing and retrieving large lists of blocks etc.
ohh, my bad
MySQL or SQLite
SQL or NoSQL?
I guess I meant is there a library that makes those easy to use with Spigot with limited lag
You should never access any database on the main thread.
Every Database is good enough as long as you access it from another thread.
Then there is no possibility for lag
I made a bad mistake the other week doing that xD
do you guys have a favorite tutorial site or video for this specific task? I've never worked with a database, this is my first foray
hi how can I make that only ops can use a command
or just how to check if the player has op
player.isOp()
Hmm. Those are two totally different and extensive topics.
First databases then multithreading. I would just look for tutorials on MySQL for now
as the driver for that is provided by Spigot.
oh good, I had just found that second one through google, glad to have it corroborated
Thank you very much!
ok but how can I get if player is op level 4
How can i call asyncplayerchatevent with bungee chat
Does BungeeChat somehow prevent that event from being fired?
Yes
Are you sure? Uninstall the plugin and see if the event is then fired.
Yes i am sure because, i try on a spigot local server and it works
Uninstall the BungeeChat plugin and see if that is actually the cause.
public static void updatePlayer(Player p) {
Scoreboard scoreboard = p.getScoreboard();
Objective obj;
if(scoreboard.getObjective(p.getName()) == null) {
obj = scoreboard.registerNewObjective(p.getName(), "dummy");
} else {
obj = scoreboard.getObjective(p.getName());
}
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
Score score = obj.getScore(p.getName());
NitUser user = new NitUser(p.getUniqueId().toString());
WizardBuildSection section = (WizardBuildSection) user.getSection(new WizardBuildSection(p));
obj.setDisplayName("§7→ §bLevel §7| §f" + section.getMana() + "§7 → §bMana");
Bukkit.broadcastMessage(p.getName());
Bukkit.broadcastMessage(section.getMana() + "");
score.setScore(section.getLevel());
p.setScoreboard(scoreboard);
}
Hey, at this Point if any players join my game, i only see my mana at the other player, but thats wrong. I like to see the mana of the other player, not my own. Can anyone help?
The output of my Broadcast with "section.getMana()" is correct but the Displayname is wrong
https://ibb.co/yd9L6GB [ImageLink] So i only see my own mana at other players
Hey! I can not cast Dynmap plugin instance to DynmapAPI which it implements.
@Override
public void onEnable() {
DynmapAPI api = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap");
}
It throws ClassCastException. Has anyone faced such a problem?
Are you including the API in your package?
yes, of course
You shouldn't
Dynmap will include it and your dependency should have a scope of provided
if (e.getCurrentItem()==blue) {
Inventory inv = Bukkit.createInventory(null, 27, format("&2" + p.getName().toUpperCase()));
for (int i = 0; i < inv.getSize(); i++) {
if (inv.getItem(i) == null) {
inv.setItem(i, pane);
}
inv.setItem(10, sharpness);
}
p.openInventory(inv);
}
private final ItemStack blue = new ItemBuilder(Material.STAINED_GLASS_PANE).setDisplayName(format("&1Enchant")).setDyeColor(DyeColor.BLUE).toItemStack();
Why when I click on the blue glass it doesn't open the inventory? I tried it with regular stained glass material but it doesn't work for the custom itemstack?
e.getCurrentItem()==blue
This is almost never true
Dont check objects with == use .equals()
ok
i implemented dynmap-api 3-2-beta-1 from https://repo.mikeprimm.com/ in my build.gradle file
ItemStack also has a better method called isSimilar()
I'm not terribly familiar with Gradle, but if you're packaging your plugin jar with the API included you'll be referencing the API in a different scope.
I just read that I can just cast an instance. I also found a few dynmap addons that do the same thing I do.
In Maven, this is corrected by adding <scope>provided</scope> in the dependency definition of the POM
Dont shade dynmap into your plugin
yes, I'm using the gradle equivalent of this. the exception occurs during runtime. it says i can't cast DynmapPlugin to DynmapAPI
what it means?
@lost matrix so i uninstall bungeechat and it is the problem
It means that you need the scope provided on your dependency.
Look into your compiled jar and check if the dynmap src code is inside.
Can we see the relevant line in your build.gradle
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
url = 'https://repo.mikeprimm.com/'
}
}
dependencies {
implementation 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
implementation 'us.dynmap:dynmap-api:3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
gett im
Should be provided, not implementation
Oh I thought I was reading Gradle did it that way too
Sorry @tall basin, like I said I'm not that familiar with Gradle
You usually use compileOnly, implementation, api, compileOnlyApi or runtimeOnly
I think I was reading about a Gradle plugin that does that.
Ye
hi, how can I put all of the message in a config string? I saw something talk about using % but I cant seem to find anything
like how would I add for example an int which changes
@raven rampart, @ivory sleet, @lost matrix
yes it worked. i used compileOnly. thank you all
how would I add this + sec which is an int, to me "color_of_numbers" config String
Again as last time:
You should not read from a config on runtime.
When the server starts -> Load all your data that you need from the config into variables, classes etc
how do I do this? I'm making a second class to load all the data... idk if it will change anything with my goal
Okay, I am feeling like an idiot here trying to create a double chest.
location.getBlock().setType(Material.CHEST);
location.getBlock().getRelative(BlockFace.WEST).setType(Material.CHEST);
Chest chest1 = (Chest) location.getBlock().getState();
Chest chest2 = (Chest) location.getBlock().getRelative(BlockFace.WEST).getState();
((org.bukkit.block.data.type.Chest) chest1.getBlockData()).setType(org.bukkit.block.data.type.Chest.Type.LEFT);
((org.bukkit.block.data.type.Chest) chest2.getBlockData()).setType(org.bukkit.block.data.type.Chest.Type.RIGHT);
You need to set the changed BlockData back on the Block
Like this?
location.getBlock().setType(Material.CHEST);
location.getBlock().getRelative(BlockFace.WEST).setType(Material.CHEST);
Chest chest1 = (Chest) location.getBlock().getState();
Chest chest2 = (Chest) location.getBlock().getRelative(BlockFace.WEST).getState();
org.bukkit.block.data.type.Chest chest1Data = (org.bukkit.block.data.type.Chest) chest1.getBlockData();
org.bukkit.block.data.type.Chest chest2Data = (org.bukkit.block.data.type.Chest) chest2.getBlockData();
chest1Data.setType(org.bukkit.block.data.type.Chest.Type.LEFT);
chest2Data.setType(org.bukkit.block.data.type.Chest.Type.RIGHT);
chest1.setBlockData(chest1Data);
chest2.setBlockData(chest2Data);
Crap. That is the state
Not sure why you need the BlockState here.
I need the state for later, but I need to set the BlockData back on the block and not the state
right?
Yes
Well, aside from mixing up my LEFT/RIGHT EAST/WEST, it worked. Thank you @lost matrix
Did they change how the PlayerList.getStatisticManager worked?
Before i could have custom NPC with a spiecal uni character in the name, but now it can not and errors on the npc create when trying to create the npc
the thing is that I want to write the string in config. But then somehow when I call the config string, it takes the int value or something
I'm rly confused on how to do
literally put this in a single config thing
so a string + an int but somehow have it all stored in a config string
wanna do something like this in my config
apparently percentages are usable
but I cant find anything online
just a mention
I need all of it to be in the config file
this is what I put in config?
???
my sendmessage should just look like this at the end
oh kk I see
yeye I see gonna test
is there a way to not need to set and directly write it in the config?
well instead of doing a command to setString(....
directly manually in the config do it
well I just want to be able to completely change the layout of the sentence from config
like change the order of strings, rewrite some of the strings etc
Tyty ill test out some stuff
I have a bungeecord plugin that runs a SocketServer which spigot servers connect to. However, it’s causing a lot of CPU usage and crashes of my entire Linux server (admins thought I was mining Bitcoin with it lmao).
The way I’m doing it is just running a runnable asynchronously to accept sockets which starts a Client thread (this is where I get the huge CPU usage) which has a while loop to read from an input stream. I’m really confused why this takes so much processing, is my approach wrong? I can provide code if needed.
definitely do not create a thread/user
I'd use a tick system, just like minecraft
you can use 20 ticks, every tick loop through the users and see if they sent a packet
clients*
I am struggling to set the custom name of a chest. I don't understand why this isn't working:
((org.bukkit.block.Chest) location.getBlock().getState()).setCustomName("Whatever I want");
Store the state, as after changing it you have to apply it
a BlockState is a snapshot of the Block at that point in time
why does playerinteract event get called twice from a right click? google said it was because of the offhand but i implemented their fix and it didn't work
Two hands. It triggers for each
yes, how do i tell them apart
I'm not seeing setState,
update
event.gethand doesnt work
bump 👽
it always returns HAND
Ugh. I remember now.TYSM
both the LEFT_CLICK_AIR and RIGHT_CLICK_AIR are called when i right click
You are not pausing yoru while loop for other things to happen?
Yes, once for each hand
ok, but how do i make sure that only 1 gets processed
If you only want to run your code on right click air if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
if (event.getItem() == event.getPlayer().getInventory().getItemInMainHand())
thanks
Anyone have any idea what changes here and why its trying to create the stat file for the NPC with the name and not the UUID?
because thats how you wrote it
what?
A stack trace only tells us there was an error
In PlayerList.class it should be trying to make the file using the UUID but doesnt then tried the name and fails.
I know that
I am asking why its not trying it with the UUID
You've shown no code so its impossible to say
That is in spigot
it its that false if clause on file1.exists() but shouldnt cause the uuid is part of the gameprofile and the NPC
so it should create
Is there a way to create a beam, like a beacon or when and end gateway is created?
I'd guess it would only create the file if the player was on the server, the name file is probably a legacy fallback.
...
NPC, so not a real player?
so why did it work fine till a update for spigot went out?
Was working fine like 1 month ago
Code was not changed based on what i can see in the patch in git for spigot for that class
No clue as I don;t deal with nms
Mob Pathfindergoals Question
Have you tried forcing a save of your PlayerList profile?
Does your NPC exist in the PlayerList?
ok elgar
It happens on NPC create on the super
It actually calls PlayerList.savePlayerFiles(EntityPlayer) ?
so how would I read the config file ive created, and store the list of that config into a HashSet<Location> ```private static final HashSet<Location> points = new HashSet<>();
private static final DataManager data = new DataManager();
public static void getPointsOnFile() {
points.addAll((HashSet<Location>) data.getConfig().getList("Data.SpawnPoints"));
System.out.println(points);
}
public static HashSet<Location> getPoints() {
return points;
}```
im still on this
You can;t cast List to Set, but you can Set<Location> points = new HashSet(config.getList...);
I sent a picture of the code above
it tried to create the file.
I might have found a way around it using a overlord of the nms method
whats the difference between Set<> and HashSet<>?
Set is the Base class of HashSet
You on current or 1.8?
spigot
yea 1.17.1
k
I overrided the getStatisticManager in the PlayerList.class in my HumanEntityNPC class and pass in a empty class set to force it to bypass and never create it
They get wiped anyway
Dont save anything on the player save file store all that data in a db
Pretty sure they only get wiped if you do it
server gets destoryed on restart
ah ok
the container is destory and re-loaded clean from a image
yep, docker
ok im so fuckin lost
Show what you have so far
on enable im trying to save the locations into a HashSet from the locations that are inside my file that way when I set the values in the config again I will keep the values that we're also previously in the file
yes
yes
Set<Location> points = new HashSet(data.getConfig().getList("Data.SpawnPoints"));
System.out.println(points);
}``` I tried this but I get NullPointer
is the path correct?
how do I get past the 16 scoreboard char limit in 1.8.8?
Scoreboards support up to around 64 characters but only 16 printable
well I got this ```st
[00:34:23 ERROR]: Error occurred while enabling Zenon v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Team name 'score.criterion.1' is longer than the limit of 16 characters````
private static HashSet<Location> points;
private static final DataManager data = new DataManager();
public static void getPointsOnFile() {
if (data.getConfig().getList("Data.SpawnPoints") == null)
points = new HashSet<>();
points = (HashSet<Location>) data.getConfig().getList("Data.SpawnPoints");
System.out.println(points);
}``` this makes sense no?
if theres no locations saved it creates new set, if there are points then it creates a set with those points
try it?
it doesnt work, it overrides the file with the new set even though there were locations saved
As I said, you can;t cast a List of Locations to a set
^ you need to store the value of the loc and then load it back on server start from the config.
Also you want to be careful with loc. If you are using more then 1 world, make sure the world is loaded first or it throws a big fit
private static Set<Location> points = new HashSet<>();
public static void getPointsOnFile() {
@SuppressWarnings("unchecked")
List<Location> temp = (List<Location>) data.getConfig().getList("Data.SpawnPoints");
if (temp != null) points.addAll(temp);
}```
Ok that makes sense
what im confused on that I need a bit of clarifying is how Set<> HashSet<> and List<> all work together here
so you take the points and cast them into a List<> then if that list isnt empty then you add the list into a Set<> or HashSet<>?
Set and List are both Base classes that are extended with things like ArrayLIst, LinkedList, HashSet.
The extended types add functionality like HashSets order their contents based upon a Hash value of each object it contains
Lists can contain duplicates, Sets can not. Every entry must be unique
that makes sense
also
private static Set<Location> points = new HashSet<>();
private static final DataManager data = new DataManager();
public static void getPointsOnFile() {
@SuppressWarnings("unchecked")
List<Location> temp = (List<Location>) data.getConfig().getList("Data.SpawnPoints");
if (temp != null) points.addAll(temp);
System.out.println(points);
}``` ok to confirm this is correct?
but it did the same
Yes, however you need to stop using everything static.
static has its uses but not here
i only did here cause i got lazy and this is a test before moving it to my main plugin
ok
yes but this did not add to the file it over-rid the file
then you are not loading the data before saving
I want to make an item that has one function when you right click it, and one function when you left click it
I have it set up so when the interact event is called, it does one thing if it's a LEFT_CLICK_BLOCK or LEFT_CLICK_AIR, and one thing if it's a RIGHT_CLICK_BLOCK or RIGHT_CLICK_AIR
when i right click air with the item, the interact event is called twice, once calling LEFT_CLICK_AIR, and once calling RIGHT_CLICK_AIR
i am aware it's because it's being called once for each hand, but i do not know how to tell if its actually a left click, or if it's just a left and right click.
I tried using e.GetHand, and it always returned main hand. I also tried using e.getItem().equals(e.getPlayer().getInventory().getItemInMainHand()), but it didn't work.
what should i do to tell if it's just a normal left click, or a left click caused by the offhand thing
getHand() should return an EquipmentSlot HAND or OFF_HAND
oh sorry
That wasn;t your isue
It should not fire a RIGHT_CLICK_ if you left clicked
yes, but it does fire a left click if i right click
it will fire twice RIGHT_CLICK_AIR passing two different EquipmentSlot in getHand
getHand always returned HAND when i tried it. never OFFHAND
one sec
teh event fires once for me
if you have nothing in your off hand it will not fire offhand
there is nothing in my offhand?
@EventHandler
public void onClick(PlayerInteractEvent event){
System.out.println(event.getHand().name() + ":" + event.getAction().name());
}```
[03:28:28] [Server thread/INFO]: HAND:RIGHT_CLICK_AIR
[03:28:28] [Server thread/INFO]: OFF_HAND:RIGHT_CLICK_AIR```
that was clicking once left, then right, then right with a torch in my off hand
do you have an item in your off hand?
let me run a clean clas. I have other stuff in my test code that could interfere
wait hang on
i think i messed something up
any other item will work fine
exept for the item i want to use
What item?
yes, its trying to open the book so you can edit it
odd that it fires a left + right for a book though
so naturally, i should replace the item with a different one implement a cooldown
You could use a book as its only the right click that does both
left click only fires left
Hi there can anyone help to validate a Minecraft username with regular expression
This didnt work
Basically, if you receive a right click with the book and quill, set a boolean. If teh boolean is set and you see a left click with a book and quill ignore it, reset boolean.
why not just ignore the off hand?
he wants a different action on left and right click
ahh
I said
not .equals, == to avoid it being called twice
LEFT_CLICK_*, item == inMainHand
LEFT_CLICK
I want to know the best way to approach/structure a function that takes a location and over the period of 5 seconds, any player that enters a certain range of it gets launched up.
What do you think the best approach is?
We'll start there ;p
Do you mean that for a duration of 5 seconds any player withing a range of a location is launched upwards? Or they are launched upwards for 5 seconds anytime they're within range of a location?
for a duration of 5 seconds any player within a range of a location is launched upwards
I was thinking of using an armor stand to store the coordinates but im not sure where to go from there.
You're writing a plugin, right?
An armor stand?
yea... im not used to doing plugins, i have done a lot of datapacks. would a hashmap be better?
Ah you're used to data packs. That explains a bit
So you're free from a lot of a data pack's restrictions. Namely being able to keep track of locations
You can do that without an entity. We're in the code world, we can hold reference to those just in memory with a Location instance
And you really only care about the locations not anything else, so an ArrayList would suffice
oh alright
In short, whenever your command is run, you can add the location to that list. In your PlayerMoveEvent, if their current position is < x distance from that location, do whatever it is you need to do
Location has a nice distanceSquared() method for you
You could use World.getNearbyEntitiesByType to grab all players within a distance from a location.
Another alternative, yeah
would getNearbyEntitiesByType be more optimized?
And to throw them upwards take their velocity vector an increase the y value.
Well, getNearbyEntitiesByType() is cubic, so that's something to keep in mind
I am not exactly sure what the back end is doing with getNearbyEntitiesByType but it has been more efficient than anything similar i've tried to impelement.
GNEBT creates a bounding box, selects all entities in the world and returns any >= and <= your bounds
Either way you're just doing some quick comparisons
So I understand how to use PlayerMoveEvent as it is per player, but how would I use getNearbyEntitiesByType as I assume it should only be used at that location instead of each player, for the 5 seconds
There are a few ways to skin this cat. My first thought is to use a task
And mine would have been to use the move event 😅
Don't think either approach is inherently wrong
The move event with an external timer would work.
I guess ill try the player move event as I think I know how to do that
Thank you guys this was very helpful
I'd run a timer myself and trigger it every 5 ticks. No need to run any faster.
Just be sure to use Location#distanceSquared() instead of #distance() and check if <= 25. You really don't need that sqrt call
test in PlayerMove shoudl be avoided if you can.
Because it is fired so often?
yes
I mean, it's not as though listening to it is going to cause issues. It's what you do in that listener that may cause issues
And numerical comparisons are what computers do best ;p
But we should still try to minimize them
True, however he's only launching players who get close to a location so precision isn;t really needed
every method call adds some overhead
Suppose you have the added benefit also of not listening while you have no active locations
Which you would only run the task for the 5 seconds locations were active, then you have none
Yep, one check every 5 ticks, or 20 checks (possibly) per player per tick if in PlayerMove.
That’s negligible
And static methods are like sugar for instance
So it matters even less
But considering what ElgarL is outlining, 100 calls vs 1 should still be considered.
Even if it is ejected as quickly as possible.
You're still doing some comparison to eject.
Idk I mean rarely the case where you have 100 calls vs 1 call
Not often, but if everyone goes throwing code in PlayerMove, it quickly mounts up
If you use paper, it auto gens an asm event executor which is quite fast also
PlayerMoveEvent is also limited to the ticking isn’t it.
yes
Are threads considered bad for plugins? Im wondering how to remove the location after the 5 seconds
Use the bukkit scheduler
But no threads alone aren’t, it’s really the intention of them that makes them good or bad
Hi everyone! I'm getting an error in console:
[11:30:58 ERROR]: [PlaceholderAPI] failed to load class files of expansions
This is my code here, I have no idea what's causing this error. https://pastebin.com/AF9fkK16 I'd appreciate any help on how to fix it tho! thanks!
(Please ping if you respond :))
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.
However I suggest using the BukkitScheduler to schedule a method that runs on the server thread so you don’t have to implement thread safety yourself, can be a lifesaver sometimes.
Send the stacktrace also
sorry whats that?
The error trace after the error thing like
at blah.blah.blah[;]
caused by blah.blah
Blue needs someone to teach him how to build with InteliJ and not include all his dependencies.
His jar contains Spigot, PlaceholderAPI jars and all classes shaded too.
Hey elgarl
a = 5
print(a / 2)
name = prompt("Name: ")
print("Hello, " + name)
Look at this
when he's making a PlaceholderAPI expansion so it shoudl only have his com folder with his single class
custom programming lang
nice
Thanks
I did play with creating languages years ago, but that was in Delphi
it compiles some things, but if theres a function call it isnt constant
I'd not remember any of it today
all i gotta do now is learn how to parse args
could do function_call(*value) but i have to account for lists
So we'll be seeing Jimagine released soon? 🙂
Will functions be first class objects?
this is the route im taking
math ✅ - variables ✅ - builtins, final fields ✅ - functions - classes
functions are easy
but, i have to sacrifice either open end of lines or require ';'
a = 5;
print(a / 2);
name = prompt("Name: ");
print("Hello, " + name);
doesnt feel right
It doesn't require it
gonna use {}s anyways
std.print and std.prompt
One of python's biggest problems is pollution of the global namespace
Don't follow that route
Ok
Namespacing is very good
And make it strongly statically typed
Use some keyword for variable declaration so it's explicit
let or var or val or the type of the variable
But why
Because declaring a variable is different from assigning a value
And they should look different
a = 5
a: final, const = 5
Hmm
U likey 😩
Why would it be final + const
bad example
You could do the kotlin route of var for mutable and val for immutable
a: final, protected = 5
No thats shit and confusing
Is it?
Okay well I don't think a: private would be very visually pleasing
gives it something unique and doesnt require backtracking
advancing then looping without completing
And you won't need backtracking at all if you just use a lexer generator
I have a lexer already 😩
Hm
You should let users redeclare a variable in the same scope
But keep it statically typed
That's one of my favorite bits of rust
oo
You can declare a variable with the same name later in the same scope and it replaces it
But keeps static typing
chefs kiss
Perfection
func add(int a, int b) {
if a == b {
protect c = a # optional '='
loop (4) {
c += bt.random(5)
}
} else {
z = 10
}
z = 15 # error!
}
@waxen plinth ?
Woo
Why would a = 10 error though
once the scope is left its final
scope as in { }
Also what's bt
How do I stop a bukkit RepeatingTask, the problem is that it is in a function and multiple can be running
You can keep the task ID when scheduling and cancel it later
With BukkitScheduler#cancelTask(int)
I could just do finalize b @waxen plinth
z shouldn't be visible
I tried that but im not sure how to get the int in the runnable as it doesn't work when the int is local to the function where the scheduler is running.
its interpreted
And I don't know why you would ever finalize a variable
Just declare it as final
It's being phased out
It used to get run when the object was garbage collected
anyways how do i make this namespaced feature
Just have namespaces like packages or modules
Honestly I like having them with a separate naming convention
TitleCase for namespaces, camelCase for functions and variables
normal is camelCase
builtins are snake_case
Hmm
Why should they differ?
Java is self hosted, meaning most of java's standard library is written in java
Using normal java functions, and it all acts like regular functions
Even natives
Ok
how can i remove the senders username in a tab complete i have an argument that is a custom string so it doesn't have any tab completions but when i return null it shows the senders username as an option
Returning an empty list works
Hey Quick question: I would like to connect my plugin to MySQL and have already done some research on JDBC. Among other things, I have read that the method of establishing the connection with the Drivermanager is not so good and that it is better to establish the connection with the DataSource. However, I haven't found anything that really explains in a comprehensible way (for me) what you need and what exactly you have to create and write. Can anyone help me there?
this is a great tutorial for it
https://www.spigotmc.org/wiki/connecting-to-databases-mysql/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@burnt current
I have this plugin that sends data from a client I made to a database and then the server fetches the database every second. Do you think it would be better to switch to sockets?
Probably best to stick to established software with rigorous security and support
If you know how to do networking sure but def not the first option
to shade I have to add this <relocation> <pattern>com.elunar.plugin</pattern> <shadedPattern>com.shaded.elunar.plugin</shadedPattern> </relocation> </relocations>
to the shading plugin inside pom.xml?
What packet should I use to change player name above head?
how do I send a message to the player with the number of coins?
double money = EconomyManager.e.getBalance(p);
p.sendMessage(money);
Check wiki.vg and find every packet with name or uuid information and change that
No
Wiki.vg is packet wiki
It doesn't matter what you use
@maiden briar, you are here?
Make money a string in send message
Simply add "" + or use String.valueOf
They do
Don't
Use the contents list
so (just for me to understand again) first I create a new class into which I then write the following:
MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();
private File file = new File("myPath");
private YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
then I should read the data from my Config and then configure the DataSource. I'll do an extra method for that, won't I?
work. thanks
@chrome beacon
I have 967,400 thousand on my balance. is it possible to somehow show this as well?
java.lang.ClassCastException: class com.elunar.plugin.DeathGhost cannot be cast to class com.shaded.elunar.plugin.DeathGhost (com.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @5f6837f2; com.shaded.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @4eb3ed8a)```
what does that mean?
Wdym? You want it rounded?
._.
If you want
It doesn't matter
if I write /money, it shows 967,400.
e if I send a message to players with the amount of money, it shows 967400.0
It tells you.. You cann't cast Shaded DeathGhost to non-shaded DeathGhost
so how can I fix it?
is it possible to do the same as with the /money command?
Don't cast
@chrome beacon
I just noticed that the data type Database, which I need for Database database = config.getDatabase(); does not exist at all
easy to say
Yeah now use the right DeathGhost as variable
I feel dumb now, thanks
@chrome beacon,please tell me, is it possible to do this?
Do you want to ignore all decimals
.
.
java.lang.ClassCastException: class com.elunar.plugin.DeathGhost cannot be cast to class com.elunar.plugin.DeathGhost (com.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @78d4450a; com.elunar.plugin.DeathGhost is in unnamed module of loader 'CombatLog.jar' @9997912)
where can I send a screenshot?
Now you have 2 of the same class in the server
You should only have one
I have 2 plugins that use the same API
Yeah you need to relocate then
Don't have two of the same class in the same package
wdym?
You need to change the package name in one of the jars
So they both don't contain the api in the same path
Verify
?
Verify so you can send ss
!verify
Usage: !verify <forums username>
but then I get this error java.lang.ClassCastException: class com.elunar.plugin.DeathGhost cannot be cast to class com.shaded.elunar.plugin.DeathGhost (com.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @5f6837f2; com.shaded.elunar.plugin.DeathGhost is in unnamed module of loader 'DeathGhost.jar' @4eb3ed8a)
!verify 4ebypel
Could not find your SpigotMC.org account!
@chrome beacon, I want to add a comma, after a thousand.
for example, 1,000, 1,500
Yeah now use the right one in that plugin
I.e the non-shaded one
Because that one is running as a plugin
Use a string format
how?
what should run on the server, the shaded or the original ?
what do I use in other plugins, the shaded or the original?
None preferably
?paste
here is an example of a data source getter from one of my plugins
so how can I use the api?
Kidalder.FlagWars naming convention goes brrrrr
doesnt change the fact that its package naming is crap
i do
but thats not the point
i am just saying
that your package-naming is crap and out of the convention
because your first letter is uppercase
And?
@quaint mantle I just woke up
hi, how to make the numbers be thousands
double money = EconomyManager.e.getBalance(p);
p.sendMessage("" + String.valueOf(money));
shows 1000
how do I make it show 1.000?
double
Ok also good
Divide by 1000?
double money = EconomyManager.e.getBalance(p);
p.sendMessage("" + String.valueOf(money));
shows 1000
how do I make it show 1,000?
Oh you want to format it?
yes
NumberFormat.getInstance(Locale.ROOT)
double moneyDouble;
String money = String.valueOf(moneyDouble);
StringBuilder moneyBuilder = new StringBuilder();
for(int i = money.length(); i > 0; i = i - 3)
moneyBuilder.append(money.substring(i, i + 3).append(".");
Written from my phone
Or sendMessage(NumberFormat.getInstance(Locale.ROOT).format(money))
@quaint mantle
Even String.format() also works
Hi guys I am having trouble with my code
``` trying to use my api in a plugin
deathGhost = (DeathGhost) Bukkit.getPluginManager().getPlugin("DeathGhost");
seems like you have DeathGhost each per plugin
I dont
String.format("%.3f%n", moneyDouble);
@quaint mantle try this pls
Integer i = new Integer(251);
for (Player p : Bukkit.getOnlinePlayers()) {
if (getId(p.equals(i))) {
System.out.println("test")
}
}
Why doesn't it print "test"?
why the fuck are you using Integer
What's wrong with that? Just tell me why it isn't working, please!
okay
Tell me what works the best for you
Well, for one Player could never equal an Integer (please use int instead)
what is this getId thing and why does it take the boolean out of p.equals(i) what never will be true?
getId returns 3
Even when unloading the DeathGhost plugin it says that
Made a mistake, try this again (changed in msg)
well, that is bound to fail on compile-time
you can't do if (int)
only if (boolean)
let this troll alone @lavish hemlock
public int getId(boolean bool) {
if (bool != false) {
return 3;
} else {
return 3;
}
}```
thats getId
Troll?
yep okay nope you were right that is definitely troll-quality
a white name trolling. he is not even allowed to do that
Then you need to LEARN it first
If you just started learning Java, please do not try to write a Spigot plugin.
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
IM NOT TROLLING ):<
you can learn it side by side
spigot is a great project to learn java with
but you should also do something else sometimes. otherwise you will get a false concept of programming (only serverside and with api)
error, but the Conclure method works with all numbers
Ok then use that
please help me with my issue
What is the error? I need to know for my knowledge
Listen dude, we don't even know what you're trying to accomplish with your code, and it literally isn't even valid semantically so I dunno how you got it to compile.
Go and use one of the links above to learn more about Java.
?paste
As it stands, the only way someone could help you would be to write your plugin for you :p And that's not very good for learning.
Thx
whats a plugin
Idk, you tell me.
ok thank you
What is FlagWars all about?
What's a plugin??? You realize what server your in right? Lmao
dont mind him
lmaoo
he is trolling
Just ignore it I got the class from a random plugin but if you make a config and pass it in to a method like that it should work
OK. Well, I don't know much about configs. But I have created a config file via the plugin. My question would be, how could I then pass the config correctly into the method?
Are you using a custom config?
You just need to create a config with all the info and pass it into the datasource
Sorry I gtg if you need more help dm me and I'll respond when I can
like that?: String host = yamlConfiguration.getString("localhost");
Yes but you don't need to make a string for everything just pass config.getString directly into the dataSource
Wait yamlConfiguration is referencing a config file right?
yes
infact
it is
for me at least
I learnt a lot from reading people code
I meant in a sense of copy-paste with no explanation.
Why are you getting local host? Is that the key of the host value in you config?
I actually do also learn a lot from code examples.
It's easier for my brain to read code than a bunch of terminology.
yes it is
copy pasting won't get you any where because you won't know how to adapt it to your code
even if you know how, it will be confusing
that's why i never copy something i dont understand
Oh no, that's not true at all.
Ok well anyways just get the values from the config and pass them into the datasource to configure it
I'll copy shit I don't understand but I'll figure out what it means via Google or docs.
Wdym?
I got it mixed up it is host
for me google is useless
Ok yeah make sure you are using the exact key name in the getString method
right now I need something to code so I can practice but there's nothing
ok. So I'll just store the values in variables for now
Wdym? The config values?
yes
The whole point of the config is so it's not hardcoded
oh ok so i shouldnt store the values in variables
No just pass them into the datasource like my example
Once your datasource is configured just test the connection with the method in my example and return the datasource
so I should just use
dataSource.setServerName(sqlconfig.getString("database.host"));
dataSource.setPortNumber(sqlconfig.getInt("database.port"));
dataSource.setDatabaseName(sqlconfig.getString("database.database"));
dataSource.setUser(sqlconfig.getString("database.user"));
dataSource.setPassword(sqlconfig.getString("database.password"));
okey
@unkempt peak I heard loading up stuff from config when a plugin loads then getting the value from a list / variable is better, is that true or am I misunderstanding
Yeah just replace the sqlconfig values with your config and key names
that is a common way it is done
I see
de/serialise it onEnable/Disable
o
Yeah that is probably the best way to do it. I was just giving them an example
may you show me an example so i get familar with it?
So that instead of sqlconfig.getString(database.host) it says "host" in the brackets, for example?
Okay, I'll give it a try. Thanks first
Dm me if you need anything else
bb
I will do
Hey, I heard loading up stuff from config when a plugin loads then getting the value from a list / variable is better than getting the config values on runtime, may someone show me an example? It would be appreciated.
you cache the data you load from the config somewhere.
messy example: https://github.com/Luziferium/AsyncSpawnMob/blob/master/src/main/java/de/luzifer/asm/config/Variables.java
which is being called after loading the config: https://github.com/Luziferium/AsyncSpawnMob/blob/5d327a53ad905dd819c13be91d0eb7085d11241c/src/main/java/de/luzifer/asm/AsyncSpawnMob.java#L26
not that messy but i dont like it
o
loading and getting the data out of the config at runtime (everytime you need it) isnt actually that bad but a bad practice
i mean, loading it onEnable is also at runtime
and then later you just do Variables.someVar?
yeah
thx
Ok I’ll see if that helps (went to bed so sorry I didn’t respond earlier)
If API is shaded you don't run it add as a plugin. Instead just target the API classes directly. If your plugin wants to depend on the non-shaded plugin you simply get the plugin instance and use that
why
why 1 letter variables
oh wait this is an old thing
so uh i made a 2 config files with this tutorial (https://www.youtube.com/watch?v=pGkJwiJsMi0) but idk how to use it, if anyone could help that would be great, thanks
Have you learned Java basics yet
i know some
didnt you just left the discord mr buenny?
this is how i learn
because everyone told you to just learn java first
godcipher i did but then i joined back
You are not gonna learn by asking here all the time
too bad i'm already learning
so i will welcome you back then
:p
?learnjava welcome back
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
You need to take a course or something for a few months
What would be the best way, to keep mobs respawning in a dedicated area?
Currently I set the boundingbox, and assigning the BukkitRunnable to a field inside each zone.
Then I call .runTaskTimer.
And then I check if an entity dies within the boundingbox zone, but how would I keep track of the respawn runnable, and make sure it's stopped before trying again, and making sure if 3 zombies were killed at the same time, it doesn't recall the runTaskTimer. Cause atm. I run into Task is already scheduled.
i went through like a full hour course and i went through half the codeacademy java course
got bored so i stopped
yes, you already said that :p
look if you're not gonna bother helping then just don't waste both of our time responding
keeping track of them.
You went through 1 hour and half a course, that is not enough to know java. Which you can clearly see.
But it's your choice
i do know that i do not know the basics, but i'm okay with that and i'm learning with this method
your choice but I am warning you that you won't learn this way.
^^^
I'm currently doing that, but it's not quite working out for me 😅
https://pastebin.com/XMLDkzZP
The general logic.
I have an event that checks the location of the death and then call the respawnEntity method if it's within a zone.
thats not what i meant. PDC is okay, but i would not recommend it in this case. you could either do your own custom entities which you can manage better or you can make a manager for your entities with a hashmap in it(region|List<Entity>) or wrap your entity so you can keep track of the wrapper. at deaht you check for the entity then.
Is there an event this if a wolf gets angry he gets a target?
I want to cancel that
a wrapper would make everything much easier since you can keep track of the entity, spawning location, region, etc.
EntityTargetEvent or smth
Ok I will try thanks
So would that require NMS? To make a specific entity which just resmeblnces any vanilla mob, but just has my wrapper methods aswell
making a custom entity would require NMS
Is there a way to map nms?, cause I would be lost in all the a, b, c etc...
i am not sure. didnt used NMS that much. especially not in the newer versions. but since everyone is talking about mojang mappings you could look at that
Ngl I feel like a custom entity in a case where you don't need custom pathfinder logic or other ai related changes might still be overkill
probably, but a solution.
can I make the event in main class and then register it like this:``` getServer().getPluginManager().registerEvents(this, this);
as long as you implement Listener and annotate your method with EventHandler, yeah
yes I have them
i still need help btw
also how can I put event into event
public void onLounch(ProjectileLaunchEvent e) {```
and than another one
in it
Anyone here good at nms? 👀 Im trying to get IBlockData from a spigot block
I'm trying to fetch nearbyEntities within nms, but it requires a entity as the first argument, so wouldn't that require me to keep one instance alive at all times?
Nevermind, I figured it out
What u trying to do?
Check how many of my custom mobs is in a specific area.
Try using BoundingBox's
Can bukkit/spigot methods interact with nms classes?
not sure why you would want to use nms for this?
nvm
just do
world.getNearbyEntities(BoundingBox.of(new Location(world, 0, 0, 0), new Location(world, 100, 100, 100)));
going back to this, do I need to make a separate entity for each mob class, because I tried just making a custom entity that is on the creature level, but it doesn't have the mob specific logic.
at what idea are you stuck rn?
Trying to wrap any entity, so I can intercept the die call and other stuff.
could just use events?
you would just need 1 wrapper for a LivingEntity
too messy, and I would need to use nms either way, to control their movement to be within a certain boundingbox
oh if you need to use NMS anyways just create custom entities
Alright, last questin for now I swear Why does my bukkitrunnable.runTaskLater after the delay, keep running? Shouldn't it only run once?
runTaskLater runs once