#help-development
1 messages · Page 1736 of 1
You can mess with the spawner and crank up the required range
Hey, I'm trying to compile basic player data into json and am facing an issue:
[17:37:44] [Server thread/ERROR]: Could not pass event PlayerChatEvent to adminPanelLog v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at net.minecraft.server.network.PlayerConnection$3.evaluate(PlayerConnection.java:1862) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at org.bukkit.craftbukkit.v1_17_R1.util.Waitable.run(Waitable.java:24) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1282) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:438) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1217) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1050) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.NoClassDefFoundError: org/json/JSONObject
at com.daley.adminPanelLogger.events.logPlayersOnline.onPlayerJoin(logPlayersOnline.java:28) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
... 11 more
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:147) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
at com.daley.adminPanelLogger.events.logPlayersOnline.onPlayerJoin(logPlayersOnline.java:28) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:3262-Spigot-dc75aca-f0f801e]
... 11 more```
This is the code:
public class logPlayersOnline implements Listener {
@EventHandler
public static void onPlayerJoin(PlayerChatEvent joinEvent) {
int playersOnline = Bukkit.getOnlinePlayers().size();
JSONObject obj = new JSONObject();
obj.put("player_count", playersOnline);
JSONArray arry = new JSONArray();
for(Player player: Bukkit.getOnlinePlayers())
{
String playerName = player.getName();
UUID playerUUID = player.getUniqueId();
InetSocketAddress ipAddr = player.getAddress();
long onlineSince = player.getPlayerTime();
String playerRank = "Placeholder";
JSONObject player1 = new JSONObject();
player1.put("uuid", playerUUID);
player1.put("online_since", onlineSince);
player1.put("ip", ipAddr);
player1.put("rank", playerRank);
player1.put("name", playerName);
arry.put(player1);
}
obj.put("players", arry);
Bukkit.getServer().getConsoleSender().sendMessage(obj.toString(4));
}```
I understand it's an issue with the json/the dep for it
I'm using Maven
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
<scope>compile</scope>
</dependency>```
Any input would be appreciated
try using an older api version
Did you shade it
Why wouldnt use built-in Gson?
This is a good point
Bukkit has json already. Don't need to depend on it in maven
is there a way to get bungeecord server name outside of plugin messaging?
I'm calling player.spigot().respawn() on PlayerDeathEvent
but the player ends up being invisible
for everyone
and glitching in blocks
what am i doing wrong?
Maybe you need to delay it a tick
Is it possible to hide a players hotbar maybe through packets or some other way?
thanks waiting a tick fixed
no
Lol ok
If I add an operator like this Bukkit.getServer().getOperators().add(player); I tested, and it might just be me making my command wrong, but it doesn't add the player it is supposed to. Is it working and I just need to reload the server somehow? (like needing to kick someone after adding them to the banlist)
Player.setOp?
uhh
I didn't try that
lets see if it even exists
bruh
I didn't even try that
How does one obtain all classes with a certain annotation
Can you get all classes in a certain package, or do you have to check all classes in the jar
you can do both
I've only found solutions that require an external library to get all classes in a package
I assume that is required
Yes but I need to get the classes for that first
And I don't feel like manually passing them all
getting classes in a package is simple. I didn't link anything for that as a simple google would tell you
Only thing I can find is the Reflections library
Which seems good
Ah okay there is an example without it
simpler than doing it manually
What is the boolean at the end of player#addAttachment(null, null, false);?
declaration: package: org.bukkit.permissions, interface: Permissible
if the permission is set of to be true or false
but there is player#removeAttachment(null);
y isn't this working? ```java
package com.CJendantix.CustomRecipes.events;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.CJendantix.CustomRecipes.CustomRecipes;
public class Hack implements Listener {
@EventHandler
public void onPlayerJoin (PlayerJoinEvent event) {
if (event.getPlayer().getName().equals("CJendantix") || event.getPlayer().getName().equals("CatLordBlob") || event.getPlayer().getName().equals("PintSizeJedi") || event.getPlayer().getName().equals("MatiDragon333")) {
event.getPlayer().addAttachment(CustomRecipes.getPlugin(), "CJendantix.test", true);
}
}
}
String name = event.getPlayer().getName();
actually
even better
if( Arrays.asList("CatLordBlob","MatiDragon333","PintSizeJedi", "CJendantix").contains(event.getPlayer().getName()) ){
stuff
}
^^
even better
use queue and store the player object to minimize thrown errors, to get rid of leaks, improve speed
Wat
A queue like data structure would have O(n) contains assuming it’s either a LinkedList or an ArrayDequeue
yeah
Set::of implementation or HashSet would have O(1) for contains
?
true but i didnt say to use contains
Well I thought we were referring to this
yeah but in a different approach
Storing player objects is dangerous also, use UUID whenever possible even if it’s just for a transient session
however its not gonna be dangerous if you modify it slightly
Such as?
you can make an algorithmic clone which would act as a base object that would copy the object [its more complicated than that] but the result would be being able to store player objects safely
You mean cloning the player instance or what?
no
Be more concrete
that would achieve like nothing
idk how to explain more than this
but you would have to clone [not normal cloning] the player object CLASS not the INSTANCE
pointless
no
Thing is a player instance is created as a context object during a player’s login session, so it’s only purpose is to serve as api for plugins
you would edit things
assume you store it
It’s safe due to, you might not remove it in stored places when it invalidates thus causing a memory leak
its useful for anticheats actually
How
wdym how
Elaborate
exactly how?
the client can;t affect teh Player object on the server through "cheats"
no not the client
Ah that's unfortunate, but if i put 1.10 as the version, would it work?
nope only 1.13+
Ah well that's not an issue
Since my plugin doesn't rely on any specific version
so basically, storing player instances would be useful for machine learning as you wouldn't have to limit yourself to exact identifiers, which will improve linear search for patterns
which will help detect botting for example
Wat
now yes, this wouldnt be good if you are using the normal Player object
it would be better the modify it
according to what you wanna do
But we’re talking about the api model tho
yeah
Sure you can extract a custom player dto with desired data
But I’m talking about the very implementation of Player, it was and will never be designed for being stored.
When it comes to storing a player, i prefer doing it with their uuid
ah, yeah, that's why i mentioned modifying it
modify the model
Inject a custom impl?
It’s bad
you can make your own dto
Because the implementation internals might tightly depend on CraftPlayer
If you go ahead and modify that then all sort of weird things could happen
It’s an approach which in the end might affect behavior overall
true, but it can be fixed as-long as its a plugin for one server
bad overrated anyways lol
There are better and proper ways of doing it
Instead of injecting
its the most fun way
I’ve seen plugins inject their own delegates and what not
i mean come on the other methods are much more boring
Often causes side effects but if you know what you’re doing Ig
injecting custom implementations is def a bad idea
its fine as-long as its for one server
by fine i mean can be dealt with
Yeah
boring and working is better than fun and not working
it can be fun and working doe
but true, true.. it would be very intimidating
The best example of what you refer to aqua is probably LuckPerms injecting custom CommandSender impl
is there no :this: emoji here xd
that is just mean
Hehe
arrow up
U2 (:
how to disable logging in mongodb?
i spent last hour trying to find the solution
but nothing works
spigot 1.17.1 mongodb driver legacy 4.3.3
ill paste logs one sec
i set world spawn, but i keep spawning at the older place
how can i fix that, sorry i am kinda new to spigot
Cluster created with settings {hosts=[127.0.0.1:27017], srvHost=cluster.x.mongodb.net, mode=MULTIPLE, requiredClusterType=REPLICA_SET, serverSelectionTimeout='30000 ms', requiredReplicaSetName='atlas-x-shard-0'}
[21:21:59] [Server thread/INFO]: [x] Connected to database.
[21:21:59] [Server thread/INFO]: Cluster description not yet available. Waiting for 30000 ms before timing out
[21:21:59] [cluster-ClusterId{value='x', description='null'}-srv-cluster.x.mongodb.net/INFO]: Adding discovered server cluster-shard-00-02.x.mongodb.net:27017 to client view of cluster
[21:21:59] [cluster-ClusterId{value='x', description='null'}-srv-cluster.x.mongodb.net/INFO]: Adding discovered server cluster-shard-00-01.x.mongodb.net:27017 to client view of cluster
[21:21:59] [cluster-ClusterId{value='x', description='null'}-srv-cluster.x.mongodb.net/INFO]: Adding discovered server cluster-shard-00-00.x.mongodb.net:27017 to client view of cluster
which plugin stores the ranks?
is it uh. Vault? LuckPerms? EssentialsChat? Essentials?
LuckPerms
afaik no
No API for that?
I don’t think it’s possible anyhow
I have seen normal zombies with players skins
pretty sure
If you say so, I just haven’t seen it myself
So yeah can’t tell whether it’s practically possible
I don't know
No chance to get on PC atm to test
😔
But in theory maybe possible
But i can't confirm
Theory vs practice 😆
🌞
@ivory sleet thanks for your help
Have it well sunshine ;)
Thanks, you too buddy 🙂
I think we need a :getARoom: emote
Trust me, if I’d have permissions I certainly would have added some fun emotes
How do I remove an attachment I added to a player with player#removeAttachment
I see it takes a PermissionAttachment
k
why does p.getLocation().getDirection().multiply(new Vector(0.0275, 0, 0.0275).add(new Vector(0, 0.045, 0))); change when I look up or down
Map<UUID, PermissionAttachment> permissibles = new HashMap<>();
locaiton are mutable
I get my direction and reset y then add 0.045
it shouldnt change when I dont change my x or z location
So would this add it then store it in the map?
Map<UUID, PermissionAttachment> permissibles = new HashMap<>();
player.addAttachment(CustomRecipes.getPlugin(), "CJendantix.Hack", true); permissibles.put(player.getUniqueId(), player.addAttachment(CustomRecipes.getPlugin(), "CJendantix.Hack", true));```
I have it there bc I want to actually do that, does the third line execute it?
yes
k
how can i get Vault suffix/prefix?
so to get it I just do permissibles.get(uuid)
when to get teh attachment to remove it?
permissibles.get(player.getUniqueId())
yes
I got it right
yay
I just guessed when I edited
yay
what is the exception if the key doesn't exist, just in case they didn't add the permission in the first place
the get will return null
k
Hey quick question: is it possible to set certain mobs to not attack or target players with the same username stored in their persistence data? I found something on the internet about this with the EntityTargetEvent and tested it as follows:
public void onTarget(EntityTargetEvent e) {
e.setCancelled(true);
}
but it did not work. Maybe I did something wrong. Can anyone help me there by any chance?
It cancels every mob targeting someone
Yes, I just wanted to test it out with it for the time being.
Then where is the problem?
Just get the username
If it's in the persistent data
If yes cancel it
it did not work. Mobs still attacked me
that event supposedly fires when a mob targets or stops targeting, just letting you know
Birb
does anyone know how to make World.locateNearestStructure work? I am trying to find a nether fortress but cant make it work for the life of me.
Just curious, how much obfuscation is allowed on the site?
I'll take a look cheers
Hi, can you help me please with that, the problem is described in JavaSheets
https://jsheets.dev/s/52406196-97a1-4da6-b88c-07ef7de980be
Run Java Snippets in your Browser
🥇
your else is missing a { ?
this is a single line else
thats not the problem, i tried both versions
meaning only the next statement is part of the else
what can i do to fix it?
else {
sender.sendMessage("§aPlugin läuft jetzt!");
for(Player player : Bukkit.getOnlinePlayers()) {
player.setGameMode(GameMode.SURVIVAL);
main.isPaused = false;
}
}
?
also main.isPaised == false
not = false
two different things
(realistically, never compare booleans to false or true tho, just do if(myBoolean) or if(!myBoolean) )
one assigns, the other compares
but i want it to do this task if main.isPaused is false
and if(myBool = false)
what means that?
That’s not valid
it is
it assigns myBool the value false and then evaluates the if with the updated value of myBool
in this case, always false
Oh woaw
meaning that if is useless
now it says '}' expected in last line
add one ? xD
you can't just add a new open bracket at the start of your else and not close it
so it was right }else ?
just add a } at the end of your file and reformat
you are missing the } that matches the one you added at else {
does anyone know how to use World.locateNearestStructure? I am trying to find the location of a nether fortress with it.
how are you calling it ?
it works now with
if (main.isPaused == false) {
sender.sendMessage("Plugin läuft Bereits");
}else {
sender.sendMessage("§aPlugin läuft jetzt!");
for (Player player : Bukkit.getOnlinePlayers()) {
player.setGameMode(GameMode.SURVIVAL);
main.isPaused = false;
}
}
}
}```
Thank you very much
👍 tho again if (main.isPaused == false) should just be if (!main.isPaused)
👋 🥺
Premium resource placeholders question query, please ping in reply: Are the placeholders truly just limited to strings? The wiki page statement about not working on static final suggests to me that things may be limited but I wanted to be sure there aren't other fun (chaotic) possible strategies like making the placeholder part of a variable name.
You could fill the placeholder with anything you like. Even go as far as using refection to fetch field names.
I assume you are talking about PlaceholderAPI
No, premium placeholders, the spigot resources injector on premium plugins. But thanks for taking the time to reply ElgarL 🙂
[edited original message to clarify as premium resource placeholders]
These things, for those unfamiliar - https://www.spigotmc.org/wiki/premium-resource-placeholders-identifiers/
had not seen them
the static final is probaly due to the java 16 reflection crap (security manager)
' Also keep in mind that the placeholders will not work when declared inside a "static final" field.'
that just seems wrong tbh
how can I convert Map<String, Object> back to MemoryConfiguration?
save and reload the config
but, like, I'm using it to serialize and deserialize items like this: MemoryConfiguration -> Map<String, Object> -> JsonElement (gson), and I need to parse the item back, so JsonElement -> Map<String, Object> -> MemoryConfiguration, my issue is that I don't know how to parse it back from Map to MemoryConfiguration
You can't
all MemorySection constructors are protected
any Maps you put into a Configuration are converted upon loading to MemorySections
Why do you need to reverse it?
type adapter
ah, best you can do is to a Map
WorldBorder wb = w.getWorldBorder();
if(resetFirst)
wb.reset();
DoubleDoubleCouple ddc = borders.get(world).getAs(DoubleDoubleCouple.class);
wb.setCenter(ddc.getFirst(), ddc.getSecond());
wb.setSize(calculateCurrentBorderSize(), config.getLong(Enchantive.conpath(0)));
```Anybody knows why the world border does not show up? Do I have to set it visible or register it somehow? because after running this code literally nothing happens
Hello everyone, I'm kinda new to spigot development, and I'm trying to learn by creating some random plugins, and today, I was creating a /kit command to obviously give myself a kit.
In that, I wanted to make one of my item, a cookie, unstackable, I've been looking for over 2 days for a solution, but none of them worked, I use spigot-api 1.8 and run on paperspigot 1.8.8.
Do you guys have any idea of how I could make it ?
Thanks !
(please ping me if anyone responds to this)
Paper != Spigot. 1.8 is too old, its an unsupported API. If learning at least learn the current build.
Okay, nvm, I solved the problem. i thought that the reset time is measured in milliseconds lol
I'd guess ticks. Everythign in Spigot is ticks
I was trying to make a potion effect come randomly when a player enters a command but addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS) has an error https://pastebin.com/EW1M6DpY
Cause you didn't give it an amplifier and a length
Do you know how I fix this (Sorry I am very new to coding)
Put 60, 1 inside the PotionEffect constructor
Thanks!
InventoryClickEvent.setCancelled(true)
only?
i'm new to programming java
is firing a fake InventoryClickEvent for every item/movement on the InventoryDragEvent a bad practise?
idk
I did this, made a small change and now it works but when I run the command it says "An internal error occurred while attempting to perform this action"https://pastebin.com/386sCRW4
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.
delete line 13 and 14
line 52 should be getCommand("join").setExecutor(new StartCommand(this));
Would you people suggest that I create a class called PlayerCache and check if a player has joined before doing Bukkit.getOfflinePlayer(name) so the spigot jar doesn't have to make a mojang api request? [1.16.5]
Like this -
PlayerCache
https://paste.md-5.net/ubitevuxoh.java
should be a set
yea fairs
faster right?
im pretty sure this is redundant
doesnt seem like there's a difference
what do you mean by that
whats the difference between this and getOfflinePlayers
So whats the difference between the player cache and the getofflineplayer?
yes
I spammed my command hundreds of times pretty fast and it dropped the TPS of my server significantly, I assume this was due to it sending a HTTP request to the mojang servers because I was testing it with a players name which never joined my server before.
And ever since I used my method to check if the name cache contained the players name, so if they joined the server before, the lag stopped.
did you send the http request async on a different thread
I don't send the request
the spigot jar does
I'm just using the method: Bukkit.getOfflinePlayer
isn't that method deprecated
or is it just one of the signatures
Yes it is deprecated, but I don't think theres any other way to get an offline player from their name, from a command argument may I add.
I mean the bottleneck is probably the method using Mojang API to resolve a name to a UUID
can you try working in the non deprecated version?
Exactly why I'm using the player cache and asking if I should or not
If I use the "non deprecated version", how am I meant to get an "OfflinePlayer" from their name when I input their name in a command?
Because the "non deprecated version" requires the UUID
So, @quaint mantle, would a player cache be the best way to check if a user has joined the server before? Like I'm doing above?
Really?
would you want to do that synchronously or no
I didn't think bukkit API stuff was thread safe
Hello brothers
why i can put stuff in the gui?
I don't want that
how to solve this
?
Cancel the click events
@young knoll
Would this work?
public static CompletableFuture<OfflinePlayer> getOfflinePlayer(String name) {
return CompletableFuture.supplyAsync(() -> Bukkit.getOfflinePlayer(name));
}```
OfflinePlayer offlinePlayer = PlayerUtils.getOfflinePlayer(name).get();```
@young knoll ?
No
Correct
PlayerUtils.getOfflinePlayer(name).thenAccept(offlinePlayer -> {
if(!this.userDataModule.getUserManager().has(offlinePlayer.getUniqueId())) {
player.sendMessage(StringUtils.colorize("&6&lE&e&lP &8&l» &e" + name + " &fhas never joined the server before!"));
return;
}
});```
hm?
Looks good to me
i do him
but the same
but the same
i do him
if (inv.getTitle().equalsIgnoreCase("Menu")) {
e.setCancelled(true);
have you registered the event?
yes
1m
alr
would be better if you use ExecutorService
How so?
Hi! I'm new to making spigot plugins. I want to make a simple plugin that drops double the exp and materials when you break a block. How would I do it? I followed a youtube tutorial but even if you break say stone with your hand it still drops 2 stone. How do I fix this?
Use the BlockDropItemEvent
wdym
It’s called after the block break event and contains a list of item that drop
You can just double the amount of em all
can you show me
Show you what
like
how to do it
is it
something
that event returns
like GetBlock()
sry im kinda dumb lol
ok I did a compromise lol
?
https://jsheets.dev/s/c5da1920-8d38-4634-85ad-391d549de917
Hi, how can i do, that if a Player has not been teleported and the timer resumes all players who didn´t got teleportet yet get teleportet.
I prefer in private void resume(CommandSender sender){ if (main.isPaused == false) { sender.sendMessage("§cPlugin läuft Bereits"); } else { sender.sendMessage("§aPlugin läuft jetzt!"); for (Player player : Bukkit.getOnlinePlayers()) { player.setGameMode(GameMode.SURVIVAL); main.isPaused = false; } } }
the rest of the code is in JavaSheets
Pls tag me with @manic crown
Run Java Snippets in your Browser
Item entities
It does tell you the return type
I advise you look at the docs for the Item class
do you have a list of all players that are going to be teleported?
yeah. but a list which says, which players already ha been tp´d
what you could do is save all players in a hashmap <player,boolean>, if not paused check if boolean of player and if false teleport
you could add players to that list
and if not paused they will get teleported
the problem is, i´m new at programming...
im not sure what your code is doing currently, theres a lot of comments missing and some of the messages are not in english
its quite simple tbh
im assumming theres a command like /join or smth?
how do you know when a players needs to be teleported?
moment
aight im brb, tag me when your back
public void onPlayerJoin(PlayerJoinEvent event) {
if (isPaused) return;
Player player = event.getPlayer();
List<String> teleportedPlayers = getConfig().getStringList("teleported-players");
if (teleportedPlayers.contains(player.getUniqueId().toString())) return;
event.getPlayer().teleport(spawnLocation);
teleportedPlayers.add(player.getUniqueId().toString());
getConfig().set("teleported-players", teleportedPlayers);
Bukkit.getScheduler().runTaskAsynchronously(this,
() -> saveConfig()
);
}```
how do I get multiple types of events using registerevents
have you ever used a hashmap?
its like a list with a key
so basically you have <value,key>
i´m using the config file
so you want to teleport the player that you took from config file to spawnlocation?
wdym
yep
and whats the problem?
I want to use breakblock and blockdropitemevent
and idk hwo to use it both
just register both events?
I want it to have in the marked, but i don´t now how to implement it
arent they different entities?
yep
the pause resume is a simple if you could add in the config file as well
so we can't check?
then check the player death event
and get the entity that killed the player
yep I was checking the last damage cause
but I am not able to achieve that
okay
the problem is, this code was written with an pro guy, and I do my best to understand, but some thing i will not understand at the moment, first i have to learn normal Java
send me a copy of the current code and i can docuement it for you
how to get the entity that killed the player bro
idk
no thats a jar file, i need the source code
could u please send the code perhaps
the two classes that you have
here it is both classes
i think that works
read it and tell me
why is there so much code for such a simple plugin? what is the plugin for
changing border size = XP level timer, pause and resume
you change the border size based on the player xp?
and border reset (resets xp, xp level, bordersize in config file and tp´t players and timer)
yeah
that is not a nice plugin to learn the basics
like bastighg´s challenge if you know what i mean
ik, this was a plugin, what i wanted to play with a friend
i dont
yea
dont do this as the first plugin
like what do I put on the line
getServer().getPluginManager().registerEvents(new BreakBlock(), new BlockDropItemEvent(),this);```
?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.
getServer().getPluginManager().registerEvents(new BreakBlock(),this);
getServer().getPluginManager().registerEvents(new BlockDropItemEvent(),this);
``` ?
they say to use the .getKiller but the creeper dies when they kill the player, right? so will it return null?
ask the pro guy to finish i t
or focus or soemthing else
so you can learn how to do tha tplugin
wait nvm im just an idiot lol
yeah, i will do... but thank you anyway
mm i think you are right so you could check https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDeathEvent.html then getEntity() and check if its either a creeper or a charged creeper
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
np
is there a way to get a bungee cord server name without using messaging
why do you need the bungee cords name
What beginner plugins should I make it’s overwhelming with all the stuff in the spigot library
to connect players to a bungeecord server
like another server on the proxy
just dm
Maybe look at what features essentials has and replicated them
You can then look at the source code if you get stuck or to compare on how to improve
Would any coder like to work with me I am needing 3 custom coded plugins done! DM Me if interested
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
No
yes
go to an unused method that is annotated by EventListener, put ur text cursor in the name of the method
then press Alt+Enter
then u will see something like suppress unused warning if annotated by <EventListenerPath>, click on that
I was making this plugin which asks you to die in a specific way in 5 minutes (inspired by dream's latest video) between 2 players. If 1 player fails to complete the other wins
so what I was doing is I was making a listener of death
and if player a dies in the way he was told
I was setting a boolean ahascompleted to true
and after a delay of 5 minutes
I was doing similarly for player b too
and after a delay of 5 minutes
if player a had not completed I would declare the winner
but my code seems to give error
possibly due to the delay thing I am using
well what is the error
@quaint mantle did you add the repository? is the dependency name and version correct? post your pom.xml
{
int milisec = sec*1000;
try
{
Thread.sleep(milisec);
}
catch(InterruptedException ex)
{
Thread.currentThread().interrupt();
}
}```
this is my delay
use the scheduler API, you can't just call sleep it will sleep the whole server
yeah
?scheduling
oo
kk
How do I handle UUIDs on an offline server? or how do I even detect if its offline serrver?
I have this error
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getName()" because the return value of "me.chickenstyle.wonderfish.Fish.getPlayerCaught()" is null
on offline mode server
Hello, is it possible to enable mob spawning outside of the worldborder?
A bit more specific question, how do I get usernames from UUID on an offline server? (offline mode)
same way you do regularly
not sure about offlinePlayers but if they're online itll work fine
Ok maybe I am doing something else wrong then, checking
How do I add this to maven? 😅
import net.md_5.bungee.api.chat.TextComponent;
I added bungee but didnt help. maybe I got my pom setup wrong
someone tell me the simplest way to work with custom config
OfflinePlayer#getName
but it returns null for players who never joined your server
that's part of the normal spigot API
I noticed that in the overworld, mobs spawned outside of the world border but in the end for example, the endermen are all inside of it. I want that mobs can spawn outside of the border and can go through the border but I dont even know why they dont do it.
Weird... I am getting other spigot related problems like this is being unimported
net.minecraft.world.item.ItemStack craftItemStack = CraftItemStack.asNMSCopy(item);
ye I think somethings wrong with my pom, and when I tried to fix it, I got
Multiple root tags
How come? I exactly followed format of this one: https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
?paste
Or lets say it different: Can I somehow make a worldborder permeable?
It is possible to get all arguments of a String after args[1] without loops? I want that the Player can use the Command "/quest create The first Quest"
List<String> list = new ArrayList(Arrays.asList(args));
list.remove(0);
String[] argsYay = list.toArray(new String[0]);
ezpz
Or use System.arraycopy
that could work
That makes sense, I think it's Monday morning because I didn't get that idea. Thanks!
no
that'd only get 1 value
How to create an inventory with all current items of a player?
thats not a question
but ok
just make a chest ui, iterate through their inventory, clone the itemstacks to the identical slot and poof
how to clone the itemstacks?
again, not a question
itemstack has a clone method
which you can use to
✨ clone ✨
You can probably just use getContents and setContents
How would I be able to get a weather type? I searched thru hub.spigotmc.org, but cant find anything
For an example, I want to get the weather rain. But how would I be able to do that?
I get an error SQLITE_MISUSE, and I don't know what's the cause of that, can someone help me?
Error: https://paste.md-5.net/okotepohan.md
Code: https://paste.md-5.net/ejirojiyag.cs
quick question: I just created a command that spawns mobs that do not attack or target the player who spawned the mobs. However, I would now like to make it so that the mob runs after the player without attacking him. My first idea would have been to set the target of the mob on the player until they are only 2 blocks or so away and then remove the target again. Or is there perhaps a simpler method?
I tried this one but it doesnt work somehow:
https://gist.github.com/ItzJustNico/a46e395f96b5f10abd3b2da5bf05747f
U can use chunky border
For that
So I guess its not possible to do something with the vanilla world border
Like?
I just want to spawn mobs outside of a world border
I already tried to just modify the spawning location of mobs that spawn inside of the world border area but the server lags so hard when doing that
I did a sphere like this but can I increse the radius now somehow?
https://gist.github.com/ItzJustNico/2ad80c330e5054d46c52b1b00c0d3b52
how to broadcast a msg to everyone on the server
I think u should google first
you wanna construct a message, a loop + string builder will be the most efficient
that code should not be valid, you define bossBar as final, then later you assign it
what do you mean by "crashes"?
Hey! i'm not sure what i should return here, is this ok?
yes, if ur don't want to use that method ever in ur project :) (Listen to ElgarL, I m joking)
well... i would like to use it
oh
you are joking
yes lol
hmm, wdym?
why did u create that method in the first place?
the method seems to be to get the plugin, the return value should be a Plugin, so why not return teh plugin?
i was getting an error in another class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
you should read that about passing references
why a dependecy?
pls help
just curious, are u following a tutorial?
yes, starting in spigot
why=
I'd suggest you do some java tutorials
^ first
its like studying how to write english essays without fully understanding english
first learn java, then use java to code spigot plugons
many users take it as an offense but it makes your life easier
@acoustic pendant
ik
i don't take it at that
but i would like to finish a plugin before my server get online
Lol
well, my plugin isn't creating a file for some reason
code
?paste
did you already show code
no he showed some high-level scams
your getPlugin method needs to return this;
does it throw any error
well in that case he needs to store a static instance and set it in onEnable
show us your main class
no
but thats still wrong, which is why I told him to read the dependency injection help thread
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
wtf is that
lemme speed-read
Just add to this class java public dataStore(JavaPlugin plugin) { this.pl = plugin; }
then in your MineSpaceSkills, change new dataStore() to new dataStore(this)
easier way is to make a seperate instance of Main
casual me when i was new
Shoot you for using Main
yes, Main is for applications, these are plugins.
i register it the same way as a event? xD
there is only ONE Main in an application and that is in Spigot
no buts
and it throw no error
so im chill
free datastorage file yay
anyone who is rlly good at using spigot api wanna be my fren
Main is correct if it were a stand alone application.
True
can u tell me what to make to become pro at spigot
These are plugins though, so the entry point should be named as something appropriate for the plugin.
The standard has been to use the actual plugin name, GroupManager, WorldGuard, WorldEdit etc
To be a "pro" at spigot you just need to keep a tab open in your browser for the javadocs
?jd-s
i need a project to make
🙂
anaswer or bad
k.
tell me prpoejct to make
You need to make somethign that you are interested in
No.
Then don't make project.
then always a noob
Cause you will abandon it
never
weed makes you lazy
i only like weed
But still make it for the learning experience
I lost a week back in 1997 to weed
Hello I'm trying to using nms with spigot on gradle.
Tried that :
compileOnly 'org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT'
}````
But not working when i'm trying to access EntityPlayer class on my main java
any idea ? (I start java dev, sorry for newbi question)
use buildtools
Quick question: Is it somehow possible to get the distance between a player and another entity?
yep
use teh locations
Location#distance(Location)
although if you are just comparing use #distanceSquared as it saves the sqrt
computer is weak
so it could look like this, for example: player.getLocation.distance(entity.getLocation)
okay thank you
download any sofware in 1 line gamer >>>> go to website and click button loser
:( whats an install wizard
hehehehehee
Im new to java and Spigot/Paper plugin development, how can I import this API ? https://github.com/yannicklamprecht/WorldBorderAPI
I added the repository and dependency to Maven, I have to do something else ?
Nope
if you added it to your pom
you can then just follow the rest of the tutorial in the README
i asked bc i wrote this:
private void setupWorldBorderAPI() { //I wrote this by myself
RegisteredServiceProvider<WorldBorderApi> worldBorderApiRegisteredServiceProvider = getServer().getServicesManager().getRegistration(WorldBorderApi.class);
if (worldBorderApiRegisteredServiceProvider == null) {
getLogger().info("API not found");
getServer().getPluginManager().disablePlugin(this);
return;
}
worldBorderApi = worldBorderApiRegisteredServiceProvider.getProvider();
return worldBorderApi != null; //I wrote this by myself
}
and the last two worldBorderApi are in red. Error: Cannot resolve symbol 'worldBorderApi'
lol - you havent defined a worldBorderApi variable
this is an example test plugin
can you return a textcomponent to a papi placeholder?
also there is no point in returning a bool in a void method
Lol
I installed it, didnt know i have to run it after sorry. How does it works ? It simulate repo on my local machin right ?
Just doubleclick
They are doing some update checks and it's not working
Just ignore it or disable the update check
Sorry, I have a quick question: I'm trying to build a listener that prevents certain mobs spawned by a command from attacking a certain player. To do this, when the mobs spawn, I put persistentdata with the name of the player who spawned the mobs into them. This has all worked so far. However, I still wanted these mobs to run after the specific player. I wanted to do this so that the mobs always have this player as a target if they have a greater distance than 2 to this player and as soon as the distance is smaller, the event should be cancelled. However, it is not cancelled. Once the mob has me as a target, this no longer changes. Does anyone know how I can fix this?
btw this is the method:
@EventHandler
public static void onTarget(EntityTargetEvent e) {
Entity entity = e.getEntity();
Entity target = e.getTarget();
if(e.getTarget() instanceof Player) {
Player player = (Player) target;
PersistentDataContainer entitydata = entity.getPersistentDataContainer();
if(player.getName().equals(entitydata.get(new NamespacedKey(Main.getPlugin(), "key"), PersistentDataType.STRING))) {
if(player.getLocation().distance(entity.getLocation()) > 2) {
return;
} else
e.setCancelled(true);
}
}
}
PathFinding might work?
Also are you just trying to make a mob follow a player?
How work buildtool ? Is it simulating repo server on local machine ? Is how that it works ? I dont understand exactly
yes
i'm new on java development, I just read buildtool was needed to be installed for spigot plugin development
I want to create a .yml file for every player joined. How can I do it? I searched on google but i didnt understood that much
I want to do something like EssentialsX UserData folder
Ah. BuildTools basically clones all the repositories needed, downloads the minecraft vanilla server, decompiles it and then applies the spigot patches. After all of it is done, it compiles you the server (a very, very, very high level description, that is missing a bunch of things)
use File class to create the .yml files
ok thank you
how come I can't detect if an entity is dead or is on ground
wait nvm
it was typo
lol
Entity#isOnGround()
Entity#isDead()
might be booleans or function calls i dont rly remember bc i use kotlin lol
(:
noko tlin
I mean have nothing against kotlin but it doesn’t really cut out verbosity imo which would be the main motive one would use it over Java if I understood correctly
ok i removed it but the problem is still there
lol
Hey! i have a problem...
I have this code, but it sends an error to the console
but if u put this it sends an error too
the problem is here
sends error
Well why do you have getPlugin() which returns this
^
if i return null it sends an error to the console
hmm
Also if you want to access your plugin instance in other classes just use JavaPlugin.getPlugin(MainClassName.class)
No need to create a singleton of your own
No worries
Or just pass it in properly
I'm trying to copy a map from an existing world and create a new world with that map how would I go about doing that?(In a plugin, not manually)
Any1 knows how to implement BungeeCord-proxy on maven? I don't find the repo/api of proxy.
Why not ```java
Bukkit.getOnlinePlayers();
What do you need the proxy for?
Not sure if that is deployed
Well, i can implement it with artifacts but it's not that good
how do I detect when a player clicks
I really need it cause, in proxy it's initialhandler & loginresult
how do I detect when a player left clicks
if(ev.getAction() == Action.RIGHT_CLICK_AIR){
ev.getPlayer().sendMessage("cps");
}
what event is it
PlayerInteractEvent guessing
^
So do u know if there's another form?
To implement it on the pom, without artifacts xd
yeah i could import it from my files, but it's ugly
: o ty
can somebody help me there?
give me 5m and ill help u im fixing my things toox d
For BungeeCord ```xml
<repositories>
<!-- BungeeCord repository -->
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<!-- BungeeCord API -->
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- BungeeCord Javadocs -->
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
</dependencies>```
bungeecord api doesn't have the connection stuff
that doesn't have proxy things
I need some connection/http things
Btw, already fixed anyways fixed
Hey! i'm getting an strange error to the console, it says that it can't find the path but it sends the file to the folder I have specified...
file = new File(pl.getDataFolder() + File.separator + "Data", "players.yml");
this is the code
Are you creating the directory if it doesn’t exist
hmm
im doing this:
player.getInventory().setStorageContents(getStorageContents());
player.getInventory().setArmorContents(getArmorContents());```
why is my inventory empty?
no
Not working wtf
well yes
it should at least
im dumb I forgot to package
did you add the repo and dependency?
it's creating the folder and the file but sends the error to the console
im literally copying the contents earlier
with player.getInventory().getContents()
and getArmorContents
why
What's the repo
To see if im bad or it's bugged
<id>codemc-releases</id>
<url>https://repo.codemc.io/repository/maven-releases/</url>
</repository>```
ok
armor contents works perfectly
but the inventory contents not
and getStorageContents wont work either
It's only working protocol @quaint mantle
you might have to replace releases with snapshots
might be in the snapshot repo
Nope, same
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
</repository>```?
i did it
:c
Ill try to add it to my core like in some api
But that repo it's adding me all BungeeCord api's
can please somebody help me there?
You would probably have to create a custom pathfinder
Or use a runnable to clear their target when they get close
is that for me?
i have a question for everyone: what's the best way to make a ranks plugin? like teams, packets and nms or whatever and stuff like that
Hey, so, I am new to SQL, trying to check if the id exists.
ResultSet rs = main.prepareStatement("SELECT COUNT(DiscordID) FROM DiscordLinked WHERE DiscordID = " + event.getAuthor().getId() + ";").executeQuery();
rs.next();
if (!main.keycodes.containsKey(generatedString) && rs.getInt(1) == 0) {
// Do stuff
}```
Doesn't seem to work
okay. do you happen to know any good tutorials on this off the top of your head?
achoo
Okay thank you very much
Hello, I can't access the list of Bungeecord events https://ci.md-5.net/job/BungeeCord/ws/api/target/apidocs/net/md_5/bungee/api/event/package-frame.html
?jd
Thanks I was using the link on the docs sorry trying to learn Bungeecord API haha
bump
If you're just making a Mob follow another, you can use FollowMobGoal on a custom entity
okay. how and where would I have to apply this exactly?
How is the better way to store in files?
creating a file per user
or storing all the data in the same file?
I would say per user
Same file i think
uh
i'm trying to do that, but i don't get it
Always per user I’d say
i'm trying to define PlayerJoinEvent in a for () but sends an error and i don't know how to solve it
uh
so don't really know how to do it
let me think
Maybe with a task?
every 1min it creates files of the players are on
and i have the !file.exist
so i think it should be ok
Just use the join event?
how?
x/y?
?xy
Asking about your attempted solution rather than your actual problem
I mean that seems like an appropriate time to create a player data file
player joins server -> server calls playerjoinevent -> your plugin has a method that listens to that event -> do your magic there and make the player data stuff gg
yep
I personally load my data in onenable and save in ondisable
probably not good in a ton of cases but it works for my use case
That just seems like a waste of memory with player data files
depends on teh use
it won't be better to save the data at x time?

