#help-development
1 messages · Page 1357 of 1
U need NMS
you need nms packaged version
are u using maven?
if so, change “spigot-api” to “spigot” and refresh your maven imports
does anyone has knowledge of JDA?
I do.
can you maybe explain to me, what a guild is? i still dont get it, and couldnt find anything on google
isnt guild discord server?
if so, i dont know why guild#getMembers() only returns this:
[20:57:30] [Server thread/INFO]: [MB:UtilsBot(U:UtilsBot(***) / G:Rivex-Network(***))]
i mean... there are like 40 people on my dc
because it only returns cached members
i have no clue what that means xd
pretty sure you need to enable a gateway intent and specify a cache policy when you are creating the JDA instance
How would i detect what a player eats, is it an event?
PlayerConsumeItemEvent or smt
PlayerItemConsumeEvent
almost
the paradox... which event is it 👀
javadocs
guess event.getItem()?
JavaDocs are this reading thing
k
actually pretty simple
ill read docs
?jd
package index
you open them, read and learn
oh theres a cmd for the docs lol
yes
it's .getitem
i guess this is right?
builder.setMemberCachePolicy(MemberCachePolicy.ALL);
looks like
.getitme doesn't exist
.getitem doesn't exist
ok .getItem
Does anyone know how to keep a ResultSet open after closing a Connection in a try-with-resources statement? I want to store the ResultSet and loop through it at a later time after closing the connection with a try-with-resources statement.
that doesn't exist either
it does
Ok thanks
oh boy
FOR the INFO
yeah
Almost...
To retrieve all members:
guild
.retrieveMembers()
.thenAccept(
callback -> {
// Do stuff here
});
When building JDA:
jda =
JDABuilder.createDefault(Config.TOKEN)
.enableIntents(GatewayIntent.GUILD_MEMBERS)
.setMemberCachePolicy(MemberCachePolicy.ALL)
.build()
.awaitReady();
And make sure to tick the Guild Members thingy at discord.com/developers or whatever
facts
i mean... i only want to get a member from it's minecraft-uuid
like
from username and discriminator, but it always is null, because of this intent stuff i guess
imagine discord implementing Minecraft account connections
dafuq
verify:
5b22ca46-9470-41f4-8c79-d54f29bf2e40:
username: Rivex
discriminator: '1886'
i mean... i have it... so yeah
wouldn't be better to use their ID instead of their username and discriminator?
since those change
idk... discriminator doesnt change iirc
it does
o
i dont need. but i did to see how tf members are readable
i mean... i wanted to see why it returns null
and it seems because of the intents
retrieveMembers returns a completablefuture?
pretty sure it does... unless they changed it
oh wait
retrieveMembers is deprecated tho
Oh lol
I'm running some tasks for mysql and I want to run it async, which would be better? CompletableFuture's runAsync or Bukkit's async scheduler?
its still the same method of building afaik just different method name and return type
Material.LEGACY_RAW_CHICKEN is raw chicken right. .RAW_CHICKEN doesn't exist
isnt it uncooked_chicken or smth
Depends what you’re doing specifically but generally you use completablefuture and then use the Bukkit scheduler if you wanna sync stuff over server thread
oh i'll try that
maerial.UNCOOKED_CHICKEN isn't a thing
i meant cooked lol
they didn't say it was?
I would argue, use cf over bukkits async tasks as it’s more flexible
Thx
anyone know if its possible to close a connection and preparestatement but leave the resultset open
so i should use id's instead? :o
trying to store the resultset to be looped in a seperate method but closing a connection automatically closes all child resources :/
If the connection is closed then every child closable is also closed.
F
Why would you want to do that?
just to clean up the code a little bit instead of create a connection and prepared statement every time, and instead make a utility method like such as the following but for querying rather than updating
public void executeUpdate(@Language("SQL") String sql, Object... placeholders)
throws SQLException {
try (Connection connection = source.getConnection();
PreparedStatement statement = connection.prepareStatement(sql)) {
for (int index = 0; index < placeholders.length; index++) {
statement.setObject(index + 1, placeholders[index]);
}
statement.executeUpdate();
}
}
I mean if your result set is scrollable (since JDBC 2 iirc), then you can reuse the ResultSet itself by calling ResultSet#beforeFirst, rather than having to copy the data out of it.
Wait you want to store the actual ResultSet for later iteration?
Thats a bad idea as its just a cursor. You need an open connection for that.
Can I shove everything in the result into an object and return that instead or is that a bad idea
what object? I mean sounds fine
Depends but yes.
[21:24:20] [JDA MainWS-WriteThread/WARN]: CloseCode(4014 / Disallowed intents. Your bot might not be eligible to request a privileged intent such as GUILD_PRESENCES or GUILD_MEMBERS.)
what?
did you tick the Guild members intent thing on the website?
it saves
it still only shows itself and the server as members weirdly
How would you detect each arg in a chat message with asyncplayerchat event?
Depends on how you define an "arg"
You could just split the String at all whitespaces for example.
hey how do i disable the an player kicking other player when the player is already playing? on bungeecord
can't
if you mean bungeecord kicking someone if they're already connected to the proxy
i mean
Cant you listen for the handshake and just refuse the players connection attempt if someone with this name is already playing?
Sounds possible to me.
ill try
@EventHandler(priority = EventPriority.HIGHEST)
public void onLoginEvent(PlayerHandshakeEvent e) {
instance.log("debud");
ProxiedPlayer player = (ProxiedPlayer) instance.getProxy().getPlayer(e.getConnection().getName());
if (player.isConnected()) {
e.getConnection().disconnect(TextComponent.fromLegacyText("disconnected"));
instance.log("debug1");
}
}
returns null at the proxiedplayer method
On the handshake there is no connection established jet. Thats what you want to prevent.
You get the PendingConnection from the PlayerHandshakeEvent.
like getConnection() or getHandShake()
You should be able to figure out which of those two returns a PendingConnection object if you have a half decent IDE
sorry findout that is getconnection
didnt notice it in eclipse
so i got the pending connection and how do i check if the player is already playing?
Using very simple programming logic.
Look up what fields you see in the PendingConnection object and how you would determine if one of those Objects is coupled to a playing player and how you could check if its already in use.
is there a way to get the command on the option #TabCompleteEvent ?
In most cases you dont want to use that evebt but rather implement a proper tab completer.
Is it for your own command?
idk which to use just isConnected() but that kicks me even when im not connected
nope
thanks man String args[] = e.getMessage().split("\\s");
You can get the requested name / uuid from the PendingConnection. That should make it clear.
so like this? instance.getProxy().getPlayer(e.getConnection().getName()).isConnected()
that doesnt work
You are getting closer.
You have a very simple task.
Check if a name or uuid is already associated with an established connection
so i need to check if uuid is connected already? or
Is it for a server in offline mode?
yes
Then UUIDs are not the way to go.
Show what you have tried so far.
hello how do I make plugin enable after all worlds load?
do everything in a runnable in the enable
instance.log("debud");
if (instance.getProxy().getPlayer(e.getConnection().getName()).isConnected()) {
e.getConnection().disconnect(TextComponent.fromLegacyText("lol"));
instance.log("debug1");
}
but i think that should happen by default
guys
this will make it load after server start
i cant connect to my mongoDB
do load: POSTWORLD in plugin.yml @unreal kayak
@quaint mantle Your bungeecord should be in online mode (and configured) so its authenticating with Mojang.
ConnectionString connString = new ConnectionString(
"mongodb+srv://user123:pass123@database.gpcfc.mongodb.net/database?retryWrites=true&w=majority"
);
``` it is giving an error here
thx
the server i develop for is only for cracked users
You load POSTWORLD on default so if you iterate through all loaded worlds in your onEnable then you can cover the 3 basic worlds.
Then you should dynamically support world loading by using the WorldLoadEvent and the WorldUnloadEvent
ah ok
yeah im like trying to disable the kicking the players after the player connects with the same name
can some1 help me?
something like authme does with You logged from another location
no dude I just making the api of my plugin, Arena#isEnabled is always false if world not loaded and arena won't load on startup if world not loaded.
Your approach is right. And im pretty sure whats wrong.
Do you see any errors in your proxy?
do i do codeblock or paste?
I dont really care. I dont mind code blocks.
22:19:49 [WARNING] Error dispatching event PlayerHandshakeEvent(connection=[/127.0.0.1:5920] <-> InitialHandler, handshake=Handshake(protocolVersion=340, host=localhost, port=25577, requestedProtocol=2)) to listener pavlyi.astreans.auth.listeners.BungeePlayerListener@15aab8c6
java.lang.NullPointerException
at pavlyi.astreans.auth.listeners.BungeePlayerListener.onLoginEvent(BungeePlayerListener.java:103)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
at net.md_5.bungee.event.EventBus.post(EventBus.java:46)
at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:399)
at net.md_5.bungee.connection.InitialHandler.handle(InitialHandler.java:315)
at net.md_5.bungee.protocol.packet.Handshake.handle(Handshake.java:44)
at net.md_5.bungee.netty.HandlerBoss.channelRead(HandlerBoss.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at```
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:253)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:515)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at```
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Unknown Source)
so paste?
NullPointerException @ BungeePlayerListener line 103
Pretty much what i expected.
yea
Let me guess. Its this line:
if (instance.getProxy().getPlayer(e.getConnection().getName()).isConnected()) {
yes
Nice. Then fix it. NPE is Java 101.
i still need help :/
what?
And you expect us to help you without providing the actual error i suppose? 
you're right xD sry org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/mongodb/ConnectionString here's the error
the class is not found
You didnt shade the java mongo driver in your plugin
7smile7 could you tell me how to replace the error?
how do i do that
i already imported everything
and gave the right dependencies
Take it slow. Create new variables and dont stack method calls like that.
Then check what could be null and try to understand why a method would return null.
Are you using maven?
yes
Do you have some plugins under <build><plugins> in your pom?
@lost matrix idk how to do that
Creating new variables or finding out which method could return null?
here's my pom file
idk which methods to check and get
Add
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
In your pom
Show me what variables you have declared so far.
instance.log("debud");
ProxiedPlayer p = instance.getProxy().getPlayer(e.getConnection().getName());
if (p.isConnected()) {
e.getConnection().disconnect(TextComponent.fromLegacyText("lol"));
instance.log("debug1");
}
hey so when i have 2 of the same lines on a scoreboard it just resets to an empty line
what do i do to solve that because i need 2 of the same separators?
getting the same error org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/mongodb/ConnectionString
try
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.11.3</version>
</dependency>
replace with the you have there
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.2.2</version>
<scope>compile</scope>
</dependency>
add <scope>compile</scope>
ye
oh yea sry forgot the <scope>
Thats the old driver.
ConnectionString is part of mongodb-driver-sync
What is mongodb?
database
Oh
Show me what variables you have allocated so far.
ProxiedPlayer p = instance.getProxy().getPlayer(e.getConnection().getName());
if (p.isConnected()) {
e.getConnection().disconnect(TextComponent.fromLegacyText("lol"));
instance.log("debug1");
}
these
so, does anyone knows the solution to this problem?
?paste
To few. Take it slow and create a new variable for each method call.
Then check what method could return null. If you IDE doesnt support jetbrains annotations (eclipse for example) then just look at the javadocs
and check if the method is annotated with @Nullable
Bukkit.getLogger().info(ChatColor.DARK_BLUE + "Chereza enabled")
I'm using kotlin and i have error when im trying to use + for chatcolor like in java. How would i use?
could you just show me the example code
why dont u use maven?
Concatenation invokes toString() on each object. You could just explicitly call ChatColor.DARK_BLUE.toString()
wdym? i already use maven?
okok
thanks mate
Can someone please explain the dropchance in percent?... my head is smoking and my brain is about to explode xD
how would i get placeholderapi placeholders into my scoreboard plugin
String playerName = ...;
ProxyServer proxyServer = instance.getProxy();
ProxiedPlayer proxiedPlayer = proxyServer.getPlayer(playerName);
Plus read this:
https://ci.md-5.net/job/BungeeCord/ws/api/target/apidocs/net/md_5/bungee/api/ProxyServer.html#getPlayer-java.lang.String-
on that just a tad confused
Do you use maven?
maven is not an IDE
If you dont use maven then dont bother with APIs from other developers.
I mean... you could actually just download the jar and add it to your plugin manually
the plugin jar?
tried this doesnt work
String playerName = e.getConnection().getName();
ProxyServer proxyServer = instance.getProxy();
ProxiedPlayer proxiedPlayer = proxyServer.getPlayer(playerName);
if (proxiedPlayer != null) {
instance.log("hahah");
e.getConnection().disconnect(TextComponent.fromLegacyText("hahaha"));
}
Then try listening to the PreLoginEvent. It can be cancelled.
7smile7 how would I add a plceholder PlaceholderAPI.setPlaceholders thing into this? https://paste.md-5.net/lasopoxipa.cpp
https://gyazo.com/b1af4c2a26535324690fcf87c5ead800 does anyone know why my compiler does this?
its a smiley face tho!
See what this looks like with the default font...
haha cute but not wanted lol.
lol
default font?
default font
Ah ok. What version are you on?
That was a known bug back in the days.
Just search for some forum posts from half a decade ago.
did this and gives me error https://paste.md-5.net/hiyolifule.bash
@EventHandler(priority = EventPriority.HIGHEST)
public void onLoginEvent(PreLoginEvent e) {
instance.log("debud");
String playerName = e.getConnection().getName();
ProxyServer proxyServer = instance.getProxy();
ProxiedPlayer proxiedPlayer = proxyServer.getPlayer(playerName);
if (proxiedPlayer != null) {
instance.log("hahah");
e.setCancelled(true);
}
}
going to take me years lol
You need to learn how to resolve a simple null pointer.
like try catch?
No. You should only use try catch blocks if you are forced to. Never voluntarily clutter your code with them.
if im not wrong connection would be null on prelogin
Thats not a bungeecord thing. Its very basic Java.
well just idk
imagine learning java before learnning the apis
i did learn java a bit
lol
You have an event that is packed with information. Use it.
which event?
The event you are currently listening to
and that information?
so like getConnection()
what is line 55
hate that bot
Your code looks alright actually.
Do you still get a NPE?
fwcool is what they wanted alright
whats npe
yeah but how would I fix that?
Thats what the tutorial u gave me showed lol
and these throw an error aswell
what route should i go?
Math.toIntExact(System.currentTimeMillis())
Your cooldown is larger than 2^31
So about >70 thousand years
wait
thats a lot
delta is just the difference between two values.
So the delta of 1000 and 1005 is 5
...
same
seen*
it might be called difference in some places
How would I do a Unix timestamp?
See why I hate cooldowns @sullen dome
OMG
NVM I SLOW
System.currentTimeMillis() gets the epoch millisecond
if you work with simple integers and a runnable, you probably dont even need to use currentTimeMillis
if i remember right
i looked, but dont have my old ffa plugin anymore
When the teacher says: Development is going to use math, me: the f* is a epoch
wtf is math
fr
is it a dead langauge?
like python?
so i dont have to do it 👀
what are you struggling with lol
bro
What's the best way checking if a world exists by worldname in if clause?
if(Bukkit.getWorld("worldname").isLoaded())```
i guess
or check if the world container isn't null
will try that thanks
there is no isLoaded
then use the second idea
but if (Bukkit.getWorld("name") != null) will work
@fathom timber try out this, should work for what you need.
private Map<UUID, Integer> cooldown = new HashMap<>();
private BukkitTask task;
private void useAbility(Player p) {
if (cooldown.containsKey(p.getUniqueID())) {
//still on cooldown
return;
}
//use ability
cooldown.put(p, 15); // 15 means 15 seconds cooldown
task = Bukkit.getScheduler().runTaskTimer(Main.getPlugin(), () -> {
if (cooldown.get(p.getUniqueID()) > 0) {
cooldown.put(p.getUniqueID(), (cooldown.get(p.getUniqueID())) - 1);
} else {
cooldown.remove(p.getUniqueID());
//cooldown removed.
task.cancel();
}
}, 0L, 20L);
}
}
use ability means what you wanna have on cooldown.
bro
yeah
do I smell not storing hashmaps as Map 🤔
Me never used Maps
HashMaps are easy:
it contains a key, and a value.
if you save Player as key, and it's Rank as a value, you can for example later get his rank from that map.
what's the diff?
dont save a player as key save the UUID
because?
because it takes up memory and can cause leaks
do i see single letter variables
if you store the uuid you can properly track it and make sure it doesnt implode in on itself when the player quits
You can also use weak maps
player object can go stale and no longer reference the actual player
more versatile
updated the code
theres that
and when u use Playernames it can cause on a name change it will be seen as a complete different palyer
does anyone know of a good linux software to fork multiple minecraft servers and interact with them easily (thru the console)?
or saving player data under the players EntityId :squint:
thats why i didnt used the name lol.
didnt knew that memory issue
pterodactyl?
Used at very beginnings Player names, never again
Hi guys, can i do a question for a tip to search an API here?
There are also rare cases where 2 players have rhe same name
https://pterodactyl.io/ It's an web-based panel for servers
Pterodactyl is an open-source game server management panel built with PHP 7, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
yeah its not an immediate problem, but if you want to make bigger stuff and go to servers, its good to use identifiers and weak references
you can use player names when you only save it like for gamemodes.
but not if storing stuff that is going to be stored for a long time
isnt this for events tho?
bc ud you be logging PlayerRightclick and left click etc
it works for almost everything
i'll look into it, thanks @fading lake ;)
Do you know an API for connect Minecraft and Telegram? I'm asking for a good and without plugin API
telegram xd
Yea
telegram
oh
... why
Telegram is very famous in Italy
use Discord or IRC
telegram requires you to use its bots feature tho
telegram is mostly used by people telling you that corona doesnt exists right now
Idk any API for mc-discord
JDA
I thought that was facebook
It never existed
f
discord.py, discord.js, JDA, discord REST, discord.kot etc
Es existiert sehrwohl
@sullen dome would Main be my plugin name?
your main class
ah
Telegram is used for p.rn, Gaming and Technology in Italy
i know, i shouldnt call it main
LOL
dont judge me please :(
all mine are called Core, you're fine
https://core.telegram.org/api should be of use
We offer two kinds of APIs for developers. The Bot API allows you to easily create programs that use Telegram messages for…
i would prefer JDA for MC-Discord, but do whatever you want
U know I meant this as meme?
Ok thanks, i'm going to try JDA
yes i know
good night 🌙
Good night from the UK
from germany
How would I use Player player = ;
This chat never fails to amaze me
Good night from Sweden :)
where do you use it
wdym
we're coders, we're constantly in crisis, hence our unpredictability
https://gyazo.com/849641e2fbc0ac07f128bd9eca550ee5 instead of doing this
or Player player;
what do you want to put on cooldown
You can retrieve a player instance through a lot of different methods. Bukkit.getPlayer(uuid) could work
ahhhh
But like, the player has to actually be online for this
if you for example want to have a command at cooldown, that command execution would be the //use ability
Bukkit.getOnlinePlayers() returns a collection of all players currently on the server
you could always use Bukkit.getOfflinePlayer if you wanted it more secure, then at least you have the offlineplayer.isOnline method
then from that you can use OfflinePlayer#getPlayer
the question is where he uses it. onEnable wouldn't do anything tho
wdude
deflates
A command
an action
I would've been done if this was an event
i see
he's trying to put a cooldown on onenable :turkish_laughing_man:
gimme a sec
NO U
oh 😦
:)))))))))))))
soo
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (cooldown.containsKey(p.getUniqueId())) {
//still on cooldown
} else {
//execute your command
cooldown.put(p.getUniqueId(), 15); // 15 means 15 seconds cooldown
task = Bukkit.getScheduler().runTaskTimer(Main.getPlugin(), () -> {
if (cooldown.get(p.getUniqueId()) > 0) {
cooldown.put(p.getUniqueId(), (cooldown.get(p.getUniqueId())) - 1);
} else {
cooldown.remove(p.getUniqueId());
//cooldown removed.
task.cancel();
}
}, 0L, 20L);
}
}
return false;
}```
this should help you out
👀
obv you need to implement your command args checks etc, but you guess how it works
this makes no sense to me bro
deflates #2
thats why i made the comments
I feel like making a cooldown thing that they can just shade in their repo, cause that way they wont have to look at the code and implode
you wanna send a message on cooldown?
replace //execute command with sendMessage.
its easy
I have a function that returns the item meta of whatever item it finds with the material type above, how do I store the return value of that into a variable. I tried this but it didn't work
CheckforMaterial is the class name
and scanPlayerInv is the function name
that didnt work too
package index
thanks
Then you are doing something wrong elsewhere
some1 understands mongodb?
im looking at java stuff right now and it doesn't make much sense
wait
i might have figured it out
value = function()
yea
PermissionAttachment attach = p.addAttachment(this);
rank.put(p.getUniqueId(), rankname);
FileConfiguration file = RanksFile.getFile();
for (String perm : file.getStringList(rankname + ".Permissions")) {
attach.setPermission(perm, true);
}
for (String perm : file.getStringList(rankname + ".Denied Permissions")) {
attach.setPermission(perm, false);
}
attach.getPermissible().recalculatePermissions();
rankattachment.put(p.getUniqueId(), attach);```
So like this right?
i dont think im doin something wrong
yes, given that method actually returns an instance of BookMeta
thats all correct. if you are actually calling it and yoru this variable actually refers to your plugins main class
yes
well it returns the item meta of a book in the players invenotry
its the main class
so yea
are you using some other perms plugin that is erasing all perms?
and at what point in yoru plugin are you running this code?
public void login(PlayerJoinEvent e) {
Player p = e.getPlayer();
//if (isMySQLConnected) {
String rankname = getRankName(p);
PermissionAttachment attach = p.addAttachment(this);
rank.put(p.getUniqueId(), rankname);
FileConfiguration file = RanksFile.getFile();
for (String perm : file.getStringList(rankname + ".Permissions")) {
attach.setPermission(perm, true);
}
for (String perm : file.getStringList(rankname + ".Denied Permissions")) {
attach.setPermission(perm, false);
}
attach.getPermissible().recalculatePermissions();
rankattachment.put(p.getUniqueId(), attach);
//}
}```
i didnt want to start with PlayerLoginEvent
is this event in yoru main class?
also thats the only plugin
yes
Then there is nothign wrong in that code
No clue, if thats the only plugin That code is correct
wait should * permission work?
Do you have any other code that alter or affects perms?
no
- is not a valid permission for Bukkit
yo, anyone knows a good packets tutorial?
Im trynna send packets on entitydamageevent
hmmmm
i tried all other perms and never tried *
if you want to implement * perms you must fetch all known permissions (with children) from Bukkit and apply them yourself
wdym by "with children"
I think
permissions can have child nodes
You currently don't seem to have a single permission working. I'd not be trying others
yeah i know
fetch me their children evil milk bucket
@topaz cape I'd try a simple test of player.hasPermission to test your perms.
yeah im doin that
Well, from the code you have shown there is no reason it would not be working.
There has to be something you have failed to tell us
a normal spigot version
no other plugins
the only place that has todo anything with perms
if(perm.endsWith("*") || perm.equalsIgnoreCase("*")) {
String[] permparts = perm.split(".");
String permful = "";
for(int i = 0; i == permparts.length -1 ;i++) {
String dot = ".";
if(i == 0) {
dot = "";
}
permful = permful + dot + permparts[i];
}
for (Permission perms : getPerms()) {
if(perms.getName().startsWith(permful)) {
attach.setPermission(permful, true);
}
}
}```
public List<Permission> getPerms() {
List<Permission> perms = new ArrayList<>();
for (Permission perm : Bukkit.getPluginManager().getPermissions()) {
if (!perms.contains(perm)) {
perms.add(perm);
}
}
return perms;
}```
Location loc = target.getLocation();
player.sendMessage(ChatColor.DARK_GREEN + "The location of " + target.getName() + " is X: " + loc.getX() + " Y: " + loc.getY() + " Z: " + loc.getZ() + " in world " + loc.getWorld());```
why does that look weird? i get the poss , X,Y,Z but they have too many digits
because its stored in floats
how do i limit it to only show the first numbers
rounding
or getBlockX
getBlockX() etc
id need a method to standup a horse
when he attacks a player
but like
I dont think i can do it with this code
I mean i cant make a horse stand up by sending a player packet
Id need the horse to do the packet
okay wait
nvm
i figured something out but
where i can find
certain packets
it asks for a byte
im using this method
horse.world.broadcastEntityEffect(horse, b0);
now i need the b0
the byte aka the rearing byte
stop
edit messages is a thing 😄
Hey I was wondering how do I mutliple Tab Completer. I dont know much about them and didnt saw a tutorial for multiple ones.
yes something like /skycore perms add. Where perms and add is auto completed (or rather if you press tab)
oh that's quite simple
you check args length to decide what you need to set
well you'd still only need one TabCompleter instance for that
ahh I think I understand it now thank you :)
Can anyone tell me where could i find EntityEffects?
sheep.world.broadcastEntityEffect(sheep, b0);
this here asks for bytes
so i assume there are bytes listed with entityeffects
someone in spigot forums made iron golems swing their arms
and that required a byte
so i need to find one for sheep grass eating
Guys, some1 already had this error? Plugin x v0.1 has failed to register events for class aa.aa.aaa.aaaa because com/mongodb/client/MongoCollection does not exist
https://wiki.vg/Protocol#Entity_Status this might have something to do with it
you need to shade whatever library you’re using for mongo
i already did that
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
wdym?
are you obfuscating your plugin
or did you change the error message
also whats your mongo dependency
in pom
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.2.2</version>
<scope>compile</scope>
</dependency>
wdym with obfuscating?
no, i just censured the names
D: im feeling really dumb rn
anyone know how to get the amount of items crafted with ItemCraftEvent?
@kindred solar http://maven.apache.org/plugins/maven-assembly-plugin/ look into this
you can try getting the recipe and getting the amount there
but if it’s a shift click you’re probably gonna have to do some disgusting math
ye :/
or, I can just ignore it
and if anyone reports it as a bug
I pretend it doesnt exist

couldnt find anything there
nope, tried that also doesnt work
bug == feature
Event#getCursor
im using the online mongoDB
doesnt the event get called multiple times? then
cuz even if you craft multiple items the actual result item is only amount 1
? ok and?
no it doesnt
so if u shift click that
you can check if Event#isShiftClick()
and then Event#getRecipe()
and compute the total amount using that
idk where should i run this: mvn assembly:single
ye but id like to avoid doing dum math stuff if possible
dont think it is
@kindred solar xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin>
am bad at algae-bruh
put this as plugin
guess II could just get the inventory inventory.getcontents sort it smallest to biggest then itemstack.getAmount for an easy 1 liner
that's disgusting
which is my problem
also worse performance 🙂
Plugin 'org.apache.maven.plugins:maven-assembly-plugin:2.6' not found
can u dm ur pom?
yes
Optional<Integer> amount = Arrays.stream(event.getInventory().getMatrix()).filter(Objects::nonNull).map(ItemStack::getAmount).sorted().findFirst();
eh doesnt look too bad.....
Isnt OptionalInt a thing
depends
I mean I just instantly converted that to .orElse(1)
since it shouldnt ever be null anyways
well either way you would use mapToInt instead of map then
since if theres nothing in the inventory the event wont be called
iirc
i mean this is so much slower than just calculating the amount manually lol
wdym manually?
its probably negligible
I'm having an issue getting the age of wheat crops in the nearby area with this bit of code:
The error I'm getting is: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState cannot be cast to org.bukkit.block.data.Ageable
int count_wheat = 0;
for( Block b : getNearbyBlocks(loc, 32, 5) )
{
BlockData bd = b.getBlockData();
Ageable block_age = (Ageable) b.getState();
if(bd.getMaterial().equals(Material.WHEAT) && block_age.getAge() == block_age.getMaximumAge())
{
count_wheat++;
}
}
like getting the recipe, getting the amount of item stacks in the recipe and then computing how many items the player could have crafted on shift click
right and how woul you compute how many items on shiftclick? cuz thats what im doing here?
wrong ageable import
Dont think it's ageable even
¯_(ツ)_/¯
let me see what I did @covert urchin
that's what someone suggested last night, and I went to sleep before I could test it.
just check if its an instance
like I can't even compile THAT
if(b.getState() instanceof Ageable)
owait no yes I can
yes, but not every block is gonna be ageable
yea let's try this, I'll get back to y'all in a minute
oh nvm im dum
ofc but your statement there is always gonna be false
I'm trying to make a citizens 2 npc that goes around and collects all the wheat from the crops 😄
and I'm fairly certain that other than that one little screw up, that the rest of my code should completely work.
but this will be just the 2nd run
you need to do
smth like Ageable ageable = (Ageable) b.getBlockData()
that will work
with an instance check
^^
that's what I got now
this tells us something different rather
are you importing the right Ageable?
there is an entity ageable aswell
you need blockdata one
@radiant aspen you can do CraftItemEvent#getRecipe() to get a copy of the current crafting matrix
you can then just use that to compute how many items will be crafted

@covert urchin Block#getState() != Block#getBlockData()
tf is this.....
now I'm just getting java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData cannot be cast to org.bukkit.block.data.Ageable
what
Oh I thought you were telling him to put that in an if statement
send code @covert urchin
yes because the block data instance does not instanceof Ageable
ooh
he didnt add the instanceof check
because it's not getState() and not... what?
you need to check if b.getBlockData is an instanceof Ageable
Swear we told you to do that like 5 times xD
what should the material be btw for the wheat crops?
is just Material.WHEAT correct?
@radiant aspen what does event.getInventory().getMatrix() return
the crafting matrix?
yes

Whats the crafting matrix?
The slots where you put the ingredients
So I want to update a huge project from 1.12.2 to 1.13.3+ how do I do it
Any tips?
u only gotta change anything that changed in the api
set teh API version in the plugin.yml and see what breaks
you'll know if it doesnt compile lol
check if it compiles -> check if it starts without errors on a server
yes to both, then it's fine
Guys, can some1 help me fixing this error? Plugin x v0.1 has failed to register events for class aa.aaaaa.aaaa.aaa because com/mongodb/client/MongoCollection does not exist.
I am trying to get the meta of this item. this is the function that gets the item from player inventory the code that I am trying to use to get the book meta from this item is
The reason I think this should work is I have used this to get a bookmeta of an item that a player has been holding.
you mean, add this to my pom file? ```xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
yes and then change the scope field of the mongo library/libraries to compile
wdym
<scope>compile</scope>
i already have that ```xml
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.2.2</version>
<scope>compile</scope>
</dependency>
cool
also add <minimizeJar>true</minimizeJar> to the maven shade plugin config
it'll prevent classes you're not gonna be using during runtime to not compile with your plugin
= reduced file size
inside what
I am trying to get the meta of this item. this is the function that gets the item from player inventory the code that I am trying to use to get the book meta from this item is
BookMeta meta = checkformaterial.scanPlayerInv(player,
Material.WRITTEN_BOOK).getItemMeta();
any Ideas?
like this? ```xml
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
now should all work?
why so complex? just scan through each item check if it's not null and the type == material, then return the itemstack's meta
U mean cut out the function?
bc that's what I thought I was doing
for item in players inventory {
if item is similar to the searching item { return the item }
}
return null
should be that simple
k
will get the first written book it comes across
null if no book is found
ok
Plugin x v0.1 has failed to register events for class aa.aaaaaa.aaaa.aaaaa because com/mongodb/client/MongoCollection does not exist.
same error
i think its cuz of this line of code MongoCollection<Document> serverdb = coffeedb.getCollection("coffeeDB");
open your jar with 7zip or any archiver and see if mongo class files exist
this is my collection
where
in your jar
open yoru JAR file
doe sit have a com folder?
me*
does that contain a mongodb folder?
no
if there is no com folder you have not shaded mogo
cuz my package files name is : me.f1nndev.proj
mongo is not
when you shade a depend it adds the class files and folders into your jar, so in not having a com dir then you do not have the mongo depend meaning it isn't shaded
yes, you have not shaded mongo
i already did that ```xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
so, what should i do now
show me your mongo depend
i have 2
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.2.2</version>
<scope>compile</scope>
</dependency>
try adding to your configuration section in your shade xml <artifactSet> <includes> <include>org.mongodb:mongodb:*:*</include> </includes> </artifactSet>
just curious, but would there be any way to implement like unit tests for commands? (preferably junit)
not sure thats totally correct
but try it
you just have to build, then check inside your jar
nop
still just a me folder?
yup
you'll need to work out the shade setting for the include then
😦
you are building with maven right?
its the middle section thats wrong. the :mongodb:
just wanna double check
good point on the build
i think i do
are you using artifacts to build?
i just did as the tutorial said
omg
It would help if you actually answered the questions asked
are you using what i sent in the screenshot?
yes
So I know that player.connect on bungeecord might return before it connects(based on impl) but is there anything that will sync wait for the player to connect
so, how do i build with maven?
Stack is pretty pog
i dont have "maven projects" section, i only have "maven" its the same thing right?
r e p l i t
Elgar uses NetBeans ?
Eclipse
ah
still not solved
I have tried Netbeans and InteliJ, but I prefer Eclipse.
i lost the entire day trying to fix it
failed to register events for class aa.aaa.aaa.aaaaa because com/mongodb/client/MongoCollection does not exist
@kindred solar right click your project and select add Framework Support. See if Maven is already selected
if its not, then your project is not a maven project and you need to add maven
Hi, can someone explain me how the age state of cactus works ?
I tried to place cactus on top of others but the age stays at 0
wdym
I mean exactly what I typed
this?
check your jar
running package shoudl build everything yoru pom is set to
you don;t use artifacts when using maven
remove those libs from your project
and now
in yoru maven projects click the reload/refresh button, top left of the window
show a pic of yoru project window
with expanded libs
Imagine using eclipse
Things dreams are made of!
yes
that looks good. its all maven references
run package again and it shoudl build your jar once more
now can i try it?
open the jar and see whats inside
I hope you didn't use the artifact again
no
it is saying that i used artifacts but i just double clicked the package thing
shouldn't i compile?
no
you could run clean
it will clear out all old files
then run package
if it still says you used artifacts you'll need someone who uses InteliJ to help you
are there any good guides for setting up a bungecord network using docker so you can have a plugin creating and deleting servers
elgarl? should i do this?
https://pastebin.com/n6TmxZGq Decrypt this crash report
oh what the hell
You have a messed up config
ok
which jar are you opening?
the jar that is compiled with maven will output in the target directory in your plugin source
is Redis threaded? like the Pub subs?
Wym threaded
will it be on a different thread instead of minecrafts
Idk depends on what lib you’re using
jedis
Idk Jedis sucks ass
iirc it isn’t supporting multithreading that good or at least the cache
Then the pub system is probably fine I mean it has to do certain things on other threads but I doubt it’s that flexible (using jedis)
I recommend lettuce or jredis
how do i listen for block set?
listen for setBlock(Block b) in like world gen and overall plugins
lemme clarify my usage
Block Set by *** -> run checks, add to list if they all pass
You can;t detect blocks changed by other plugins unless they also trigger physics events
please tell me
badly edited spigot.yml
use a yaml lint to help find the issues
Has anyone ever successfully spawned an item frame? I'm trying to spawn one using conventional methods (initialBlock.getWorld().spawn(initialBlock.getLocation(), ItemFrame.class); but I am having no success, as the itemframe can apparently not be hung at the location specified. I suppose my question is how can I make the location in the given block a location that the itemframe can be hung at?
hmm... I read through that thread, guess I will again
ah, my problem is that I am spawning it from inside of a block.
So I am trying to load a resource that is NOT in the bukkit plugin directory, I want an internal resource to be in the source code, so I simply put it in the resources folder
schema.sql
System.out.println(new String(Files.readAllBytes(Paths.get(getClass().getResource("schema.sql").toURI()))));
this says it is null though
I assume its not just a java issue and its a bukkit issue for reasons
Yeah so next problem, this is not a resource for bukkit, it is a Common library for a bungee/spigot plugin
ALSO
That is for loading from the plugin data directory
Which as I said is not what I wanna do, I want an internal resource as a java project usually would
is it inside your jar?
Yes
I decompiled it, its directly in the root directory of the plugin jar which uses the common library which has it in the resource folder
ok you are spouting a lot of words there but they don;t seem to mean what you think they mean.