#help-development
1 messages · Page 2032 of 1
u know u can set this cooldown for any item right
wait what
o shit
like the enderpearl does
only thing is
its client sided
server tells client to set it on cd
so maybe an anticheat might be needed
nope
the onl
nah just check if the cooldown has expired serverside
only disadvantage is that the client manages those cooldowns
yea this^
basically a cheat or logging off the server can set the cd to 0
in fabric you'd do ItemManager.isCooldownOver(itemstack); or smt
i am sure there's something like that in spigot
so practically any cooldown beyond 10s is useless
or was it hasCooldown
yea but if the server manages it in fabric and spigot doesnt it means its just an internal float
so i would be well able to recreate such simple tasks
i mean ppl still call me out for developing low level solutions in java
🤣
but thats what im used to from C++ and assembly
Does anyone know any Deque implementation that allows to obtain the the element at the xth position (so kinda like a list)?
And Stack is not an option
what does the "PlayerEvent" do?
it's a base class for all events in which player(s) are involved. you cant listen to it directly
e.g PlayerQuitEvent, PlayerMoveEvent, PlayerJoinEvent, ...
so it doesnt detect anything RIGHT? :)
You cant listen to it
@EventHandler
public void listener(PlayerEvent event) {...}
won't work, it will throw exception
it's just abstract class which have a protected player field and a getter for it
/**
* Represents a player related event
*/
public abstract class PlayerEvent extends Event {
protected Player player;
public PlayerEvent(@NotNull final Player who) {
player = who;
}
PlayerEvent(@NotNull final Player who, boolean async) {
super(async);
player = who;
}
/**
* Returns the player involved in this event
*
* @return Player who is involved in this event
*/
@NotNull
public final Player getPlayer() {
return player;
}
}
ok thanks
Would this work?
i need to do some stuff with spec mod thats why i don't use player death
don't see any reason why it shouldn't, but where are you checking that player is dead?
well it probably should work
yeah
so u can do Bukkit.getWorld().getEntities(), but that are all entites, can you get entites in specific block?
its the base class which other events inherit
is it possible to use package manipulation to apply custom skins to entities?
cause like
putting a 3D model on an entities head
unless you use a texturepack
or using tons of armor stands
isnt really an option
this or a textured item
if you want that kind of stuff i suggest BE lmao
BE?
iirc there's a way to use plugins and addons together
just check pocketmine's gh
is there an event to stop players from going out of their spectator target? (Similar to paper's PlayerStopSpectatingEntityEvent which allows you to cancel it to stop from going out of the target)
i mean i think c++ is superior but it doesnt offer the same as spigot
Java is fun to mod, C++ probably not
pocketmine is in php iirc
not c++
bedrock is made in c++
You could make your own that fires whenever the player spectator target changes
From an entity to null
the problem is
the player would see removing themselves from spec target
and tp'd back in
or not?
nevermind
same as u cant stop cheats
paper literally does it like that
u can only counteract them
Np 😉
From a 2018 issue (explaining how it worked because someone didn't understand smt)
am not at my pc rn
is injectNewEntity() a method from spigot?
and if so, does that cause the server to store custom entities with its custom nms modifiers?
?jd-s
Type in the search bar what you're looking for
If it's not there then you'll have to look at NMS
is there an event for that or nah
nvm
lmao
also has anyone found a solution since 1.16 to make custom entities(entities that inherit another) are restart-safe(persistent)?
other than destroying the instance and re-intantiating
hi does anyone know why this doesnt work?
package com.lions_lmao.tiktokchat.events;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEvent;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import static org.bukkit.Bukkit.*;
public class Events implements Listener {
@EventHandler
public static void main(PlayerEvent event)
{
while(true){
String filePath = "C://Users//nikol//Downloads//commentTXT.txt";
String Transform = readAllBytesJava7(filePath);
System.out.println(Transform);
event.getPlayer().sendMessage(Transform);
}
}
public static String readAllBytesJava7(String filePath)
{
while(true){
String content = "";
try {content = new String (Files.readAllBytes(Paths.get(filePath)));}
catch (IOException e)
{e.printStackTrace();}
return content;
}
}
}
while(true)
.
?learnjava Time for this
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.
what shoud event shoud i use?
what are you trying to do?
for me?
use a bukkit runnable
no
im trying to check when commentTXT.txt updates, and then send whatever is in commentTXT.txt in chat @earnest forum
make a bukkit runnable
how frequently
destroying the instance and re-intantiating is probably the easiest way
like every 5sec maybe
make a runnable
and then use runtasktimer every 100 ticks
if u dont knwo what they are look into it
but not the most convenient
wait will it work if i check every second
probably
kk
if possible i want to inject it into the servers entity map
and make the server serialize it like any vanilla entity
u know what a runnable is?
kinda
It's much easier than registering your entity and getting the server to read it from the save file
ok well
you make one
using ```java
new BukkitRunnable() {
}
it has a function
called run
kk
is it possible tho?
but how do i send something in chat without an event
new BukkitRunnable() {
@Override
public void run() {
}
}
Yes ofc it's possible
@outer steeple stop using absoloute paths
bukkit.broadcastmessage?
ik im going to change it later
kk
do you know any documentation for this though? i really dont wanna read into everything myself if someone has done it before me
if theres none id do it myself ofc
You will have to figure it out yourself. The basic approach would be to find where the server reads the save file and creates your entity. How that's being done will decide how to procede further. If it's reading from a map maybe you can use reflection. If not you might have to load Mixins or straight up patch the server
oops not done yet
i made a runable but idk how to check if the string changed
so while(Transform)??
ok
As I've said it's much easier to just spawn and save the entity yourself
Not much
nah ill try to do stuff correctly this time
wait let's forget about the checking part, this should work right?
code:
package com.lions_lmao.tiktokchat.events;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEvent;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import static org.bukkit.Bukkit.*;
public class Events implements Listener {
public static void main()
{
while(true){
String filePath = "C://Users//nikol//Downloads//commentTXT.txt";
String Transform = readAllBytesJava7(filePath);
System.out.println(Transform);
Bukkit.broadcastMessage(Transform)
}
}
public static String readAllBytesJava7(String filePath)
{
while(true){
String content = "";
try {content = new String (Files.readAllBytes(Paths.get(filePath)));}
catch (IOException e)
{e.printStackTrace();}
return content;
}
}
}
last time ive done way too much sloppy coding
what shoud i use?
Also you are trying to use a main method that's wrong
?learnjava Please just start here instead of copy pasting code that you find online
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.
i know that but idk how to change the code so that it works :/
broadcast message sends it to console too
make a runnable
kk
public static void main()
{
new BukkitRunnable() {
public void run() {
//check
}
}.runTaskTimer(plugin, 0, 100);
}
I ALREADY DID THAT
sry caps
u sent the while(true) code
so sry
whats the difference between
CompletableFuture<String> future = new CompletableFuture<>();
Bukkit.getScheduler().runTaskAsynchronysly(plugin, () -> {
String result = getResult();
future.complete(result);
});```
and
```java
CompletableFuture.supplyAsync(this::getResult);```
public static ItemStack PlayerSkull(Player player) {
ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
SkullMeta meta = (SkullMeta)skull.getItemMeta();
assert meta != null;
meta.setOwnerProfile(player.getPlayerProfile());
meta.setDisplayName(ChatColor.GOLD + "My Profile");
meta.setLore(Arrays.asList(new String[] { "", ChatColor.YELLOW + "Click here to manage your Profile." }));
skull.setItemMeta((ItemMeta)meta);
return skull;
}
``` does someone know why this is giving me this as player skull? And not my own?
The first one completes the future in a cached thread pool which the instance of CraftBukkitScheduler encapsulates. The latter completes the future with the ForkJoinPoil::commonPool or a thread factory executor
oh
Tho I suppose new CompletableFuture<>().thenApplyAsync(o -> completeAndGetResult());
and
CompletableFuture.supplyAsync(::completeAndGetResult) is effectively equivalent
package com.lions_lmao.tiktokchat.events;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
public class Events implements Listener {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("asd");
}
}.runTaskTimer(plugin, 20L * 10L , 20L * 5L);
}
}```
like this? @earnest forum
No
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
?learnjava Please
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.
probably
plugin has to be a reference to your class that extends JavaPlugin
the first number should be 0
the 2nd number is how frequently u want to do it
this doesnt help with bukkit
have u tried buffered reader
It very much does
learn java before bukkit
how can i get a key of hashmap
HashMap#get(key)
how to get key not value
what would u need that for?
stream the entryset and filter
If you're getting the keys then you're doing something wrong. Unless you're saving the map or something
limpeex I assume you want to map a value to a key
You got something called BiMap which can do that for you as its a Set <-> Set basically, or go with a linear search (either using stream or some loop)
entry set
If you're looking for a key to exist you can just do containskey lmfao
HashBiMap provides that
O
but it comes with a class of problems
Wouldn't it require both the value and key to be unique
just add .reverse() to hashmap
what if A1 points to B1 which points to A2 which points to B2 and so on
😶
tho a bijective map is one to one so it shouldnt allow that
Idk whats that
In case you're interested ||Well we have
Injective functions/mappings which are For every x contained in the key set, f(x) = f(y) then x = y must be true
Surjective functions/mappings which I dont remember the proof but its when the codomain of a functions value set equals the domain of the function value set
combining those two and you get a bijective function which is one to one||
is there a way to create enum value aliases?
I want to create multiple values for my FIREBALL value.
use a private field that you point to the same value with your enums
or should i just manually make more
uh elaborate
If you mean like having multiple enum constant fields pointing to the same enum instance, then no I believe thats rather impossible
to make multiple values point to the first one
alright thanks anyway
but technically
enum DodoType{
DODODO;
public static final DodoType EPIC_DODO = DodoType.DODODO;
}```
have u tried that?
idk if its possible (like if that would compile)
ill give it a go.
https://paste.md-5.net/calavohaqo.java is this well designed? 🤔
i modified a bit at it
looks nice, a bit hard to read what is going on inside compileFromPages but thats all
hard is probably the wrong word
but non trivial
Class<T[]> heh
i need a sample when i'm working with generics and arrays
it's not the end of the world
lol hopefully not
enum MyStuff {
A(null),
B(MyStuff.A);
private MyStuff stuff;
MyStuff(MyStuff stuff) {
this.stuff = stuff;
}
public MyStuff getStuff() {
return this.stuff;
}
}
that works
myeah, not very scalable depending on conceivable usage but sure works
yeah
?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.
dude its all just how to use variables
IT DOESNT HELP AT ALL. IT HAS NOTHING TO DO WITH MY ISSUE
what issue?
.
why while tru
use bukkit scheduler
i created custom classloader,i want load compileOnly Lib.what should I do
but variables have nothing to do with that
Thread.currentThread.contextClassloader?
it just waisted my time
and now im gonna start ⭐ K I L L I N G ⭐
@chrome beacon you just wasted my time
not cool
libs in network
there is no point in asking
how to make block by itemstack when place block or reload if we destroy block it will drop ItesmStack customitem
without drop normal item?
package com.lions_lmao.tiktokchat.events;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
public class Events implements Listener {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("asd");
}
}.runTaskTimer(plugin, 20L * 10L , 20L * 5L);
}
}```
why doesnt this work
You may need to store the data when the block was placed in storage
i have one i put the location block place in arraylist but when reload all of this gone
how to make file system cus my server don't have database
arraylist works in memory
it in plugin
you can use Configuration
huh?
serialize your data
hmm can i add arraylist to configfile?
let event extends JavaPlugin
yes,when your server reloaded load it
private Plugin plugin = urmainplugin.getPlugin(urmainplugin.class);
my english is bad
k
ok let my try thank you for support me
?
remove the first long
make it 0
and
first long?
the "plugin" variable has to be an instance to your main cl;ass
the number
}.runTaskTimer(plugin, 0 , 20L * 5L);
OHHHH
if you are using other class of main use this for plugin: private Plugin plugin = Main.getPlugin(Main.class);
ok makes sense
u need a reference to your class that extends JavaPlugin
hmm i think if him using other class of main they can make errors if main aready extends JavaPlugin
btw this is my code right now::
`package com.lions_lmao.tiktokchat.events;
import com.lions_lmao.tiktokchat.TikTokChat;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class Events extends JavaPlugin {
private Plugin plugin = TikTokChat.getPlugin(TikTokChat.class);
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("asd");
}
}.runTaskTimer(plugin, 0 , 20L * 5L);
}
`
can you show your main?
`package com.lions_lmao.tiktokchat;
import com.lions_lmao.tiktokchat.events.Events;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public class TikTokChat extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "ON");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "OFF");
}
}
`
someone help please
i created custom classloader, i want use it to load library on the network.
library is the option to use compile only at compile time.
oh ok change private Plugin plugin = Main.getPlugin(Main.class); to private Plugin plugin = TikTokChat.getPlugin(TikTokChat.class);
public class TikTokChat extends JavaPlugin {
public static TiktokChat plugin;
@Override
public void onEnable() {
this.plugin = this;
getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "ON");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "OFF");
}
}
basically
ohhh
add a variable thats static
public static TiktokChat plugin;
and then in the onEnable()
set TiktokChat.plugin to this
actually wait
make the variable private
and then create a static getter
Singleton pattern is not recommended
ok
public static TiktokChat getInstance(){
return TiktokChat.plugin
}
why not?
You can pass the Plugin as a parameter
i prefer it over dependency injection
this shoud be in main right?
I think the singleton pattern is less suitable for maintenance in most cases.
yes
I hope someone can help me
line 9
package com.lions_lmao.tiktokchat;
import com.lions_lmao.tiktokchat.events.Events;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public class TikTokChat extends JavaPlugin {
public static TiktokChat plugin;
@Override
public void onEnable() {
this.plugin = this;
TikTokChat.plugin = this;
getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "ON");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "OFF");
}
public static TiktokChat getInstance(){
return TiktokChat.plugin;
}
9
which is 9 bruh
so private static TiktokChat plugin;
yes
public static TiktokChat plugin; <--- line 9
oh
shit
TikTok
i didnt realise the t was capitalized
replace it for all of them
👍
my Events class requres Listener
?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
It's not a waste of time to learn Java. You need to know it
IT WAS ALL JUST VARIABLE TUTORIALS
That's one step. There is a lot more
IT HAD NOTHING TO DO WITH MY PROBLEM
You can't even write valid code so have patience and learn
dont start yelling now -.-
I spent like 1h - 2h to "learn" something i already knew
You need to go through the entire thing. Just because you know some of it does not mean you should skip all of it
it still doesnt help me
Knowing the programming language you're writing in does help
Not really that code wouldn't work
Even if you removed the bukkit dependency and code related to it
It's just straight up broken. Now I'll leave this conversation here
it doesnt matter what ur problem is with
learning java helps u
i didnt learn it before and i struggled
so i have to spent 1mount learning java to just make this one project, knowing that i wouldn't use java again
how else are you gonna complete the project
So you can't be bothered to learn Java so you want us to waste time writing the project for you
Just hire someone
im just gonna build a big website real quick. i dont know any html, css or javascript
lets gooo
good idea
Learning Java is always good. If you understand it you would learn it in less than 2 weeks
Learning a programming language is something that takes months if not years for someone who probably doesn't have any prior experience
public class TikTokChat extends JavaPlugin {
@Override
public void onEnable() {
registerEvents();
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "ON");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "OFF");
}
private void registerEvents() {
getServer().getPluginManager().registerEvents(new Events(), plugin);
}
in your Events:
public class Events {
private final TiktokChat plugin;
public Events(TiktokChat plugin) {
this.plugin = plugin;
}
}```
yea i think this is a bit optimistic
ye
lol ok
i feel like its not clean at all
well
thats kinda coupled
ye much better
Yeah just use reflection
Probably yes
i always make a method in the main class to register a list of Listener classes
reflection :/
ya
there fixed
Anyone know how i can achieve this in java? i tried Optional.of but same issue
orElseGet iirc
thx

is there like a bad thing about that
or is it a preference
welp time to go change that
😅 I mean for spigot/bukkit it probably doesnt matter, but for constructors you only want to initialize necessary variables and such
rarely ever include logic or such things
it becomes important to isolate that once you start testing and creating layers of abstraction
but with reflection 
hy
yeah ok but im too stupid
I am too. That's why I use reflection. If I forget to register something it yells at me so I can't forget anymore
i think im going to just give up
bruh
the only reflection thing ive done ever was a skull util to get custom skulls
https://github.com/MikeTheShadow/ComplexMMOStats/blob/1.16.5/src/main/java/com/miketheshadow/complexmmostats/utils/LoaderTool.java 😉
Takes 46ms if you don't use the forceAllClasses boolean to register everything. 
I would take a look at line 100 

looks fine to me
I spent like 8h figuring out the fastest way to do it without using an external lib.
how would u use that
Since people here complained that "reflections is such a big library"
try with resources tho but ye
just add the annotation and it would automatically regsiter it?
right
LoaderTool loaderTool = new LoaderTool(this, "com.miketheshadow.complexmmostats");
try {
loaderTool.defaultSetup();
} catch (Exception e) {
e.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this);
return;
}
where com.miketheshadow.complexmmostats is your base package and this is your plugin.
Then all you have to do is annotate your commands with @CommandLoader(command ="commandName") and voila. It auto registers commands and listeners
what if your class is just a listener
What do you mean just a listener?
there isnt a command in my file its literally just an onJoin listener
It automagically registers listeners. Commands need the annotation since they need an argument for the name.
oh so i can just put whatever
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
@LoaderTool.CommandLoader(command = "test")
The only prereq is the same as what spigot requires. The class has to be assignable from Listener.class classes.stream().filter(Listener.class::isAssignableFrom).collect(Collectors.toSet())
Yeah that's how it works for commands. Still need the plugin.yml stuff of course I haven't looked into automatically doing that stuff yet.
?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.
so if its just a listener, can i put any random thing into the command =
If it's a listener you don't need the annotation.
Why does it only execute "1" and not "2"
@EventHandler
public void onRightClick(NPCRightClickEvent e) {
Player player = e.getClicker();
NPC npc = e.getNPC();
player.sendMessage(ChatColor.RED + "1");
Human human = NinjeHuman.getInstance().getHumanManager().getHuman(npc);
player.sendMessage(ChatColor.RED + "2");
}
public Human getHuman(NPC npc) {
for(Human human : getHumanList()) {
if(human.getNPC().equals(npc)) {
return human;
}
}
return null;
}
error?
oh so itll automatically do listeners
or it hangs
No error
Yeah you just make the listener class and it does the work for you.
thats pretty neat
I have plans to make it into an actual library but it still needs some work and optimization.
try System out
Wouldn't change anything, it does print 1 but not 2
hmm ill give it a go
It's pretty untested at the moment (only tried it on the project it's in atm). So good luck.
ill get back to you
hm it doesnt seem to be actually registering anything, but no errors
if you remove the player by mistake you won't get new messages
that's why you gotta try
do i need the forceLoadAllClasses for listeners? @vocal cloud
Shouldn't need to but it's possible you need to.
I have a lot of optimizations I need to add
The forceLoadAllClasses is a WiP. Basically I open the jar to read all the class files from it. The issue is if you have a lot of libraries the poor thing spends a lot of time loading every class from them. The forceLoadAllClasses is an attempt to avoid this but might not work as intended atm.
The code doesn't do anything to the player. You see that in the code. The problem is not how I print the message
Human human = NinjeHuman.getInstance().getHumanManager().getHuman(npc); this does something that intrerupts it
Did it compile it into the jar? Unless an error occurs there isn't a whole lot of reasons why that message isn't sending
Is there a bungeecord player quit event that fires after the spigot server handled the player leave?
Hey, what do you think would be the most optimised way to get player count on all bungeecord subservers from a spigot server?
Actually, I need it to update continuously
the proxy knows how many players are connected
there's no need to keep track of this manually
Would sending a plugin message every second and caching response would be the good way?
mye
Why every second?
The server selector items should update quickly 😄
Why not player join -> update plugin with info -> player leave -> update plugin with info
That way you're not wasting time repeating the same number
It's not known from where did the player join specified gamemode. Could be different lobby or using a command
xd
What?
You mean on lobby join (any player) update, and on lobby quit (any player) update?
If so, it's not gonna work properly.
I'm just asking for an advice, docs rather show how to code something
And I told you my advice
Maybe there's a better way than spamming plugin msgs to the poor bungee
Alright then, we have the same one. I guess nothing better can be done
Thank you
Bungee has events to keep track of all this information. You can then send update messages whenever a player joins/moves servers
Why does it only execute "1" and not "2"
@EventHandler
public void onRightClick(NPCRightClickEvent e) {
Player player = e.getClicker();
NPC npc = e.getNPC();
player.sendMessage(ChatColor.RED + "1");
Human human = NinjeHuman.getInstance().getHumanManager().getHuman(npc);
player.sendMessage(ChatColor.RED + "2");
}
public Human getHuman(NPC npc) {
for(Human human : getHumanList()) {
if(human.getNPC().equals(npc)) {
return human;
}
}
return null;
}

Because God wills it so
@shrewd sentinel
Yeah, is an error thrown in the console?
Nop
Yes
what would you need that for?
you can easily obtain a list of players and on what server they are using bungee api o0
Server selector items showing player count
You decompiled it to check right?
yes
That's what I said 
so why would you need plugin messages?!
A Spigot doesn't know player count on another spigot
It needs to ask bungee about the playercount on another server
oooh now I understand what you need
your previous messages suggested you needed that information on the proxy
yeah sure you can send a plugin message every second
Whenever a bungee event fires in relation to a player joining/leaving/switching servers just send a plugin message.
I'd however just use redis
Hello everyone, would it be possible to improve the ping by setting up 2 proxies that would shorten the packets?
So something like this:
Proxy 1: This proxy is located near me and shortens the client-server packets as much as possible (less big buffers) and encodes the server-client packets to the normal Minecraft format.
Proxy 2: This proxy is close to my target server and encodes the client-server packets to the normal Minecraft packet format and truncates the server-client packets.
I hope I could explain it a little bit understandable.
pmc works fine pretty much
no
I imagine that would cause even more delay with all that processing in between
also the ping has nothing to do with the size of the data
whether you send a big package by post or a small package, the delivery truck takes the same time to deliver it
it doesn't go magically faster because the packet is smaller
No, this is false! The ping is the time from the sending to the receivering
Yes, so "this is true"
True there is some processing involved but all you're going to do is add to that processing with proxies
No, its false, because its not the latency.
you have no idea what you're talking about
i'm out, you clearly don't care what people answer anyway
have fun with your 2 proxies
How adding 2 proxies would reduce ping (latency) XD
Also, i mean mainly the latenc from my house to the "internet"
What that makes no sense at all
your whole idea is bullshit, just forget it
Latency that matters is the latency between server (spigot) and the client (mc player)
Adding new proxies would rather use more processing between each, and make the latency even bigger
Just what every1 above said
I am compiling craftbukkit right now 💀
cya next year
100% cpu 🔥
noone insulting me for using craftbukkit instead of spigot?
CraftBukkit bad. Spigot good.
You might be a retro guy
And compile mc 1.4.0
I want to check how many stuff I have to change to make my update checker work with craftbukkit
somehow sometimes people are still actually CB lol
Hello!
I use ProxyServer.getInstance().getServerInfo(server).canAccess(player) method to see if I can send a player in my server (on bungeenetwork)
Nevertheless, if the server just started starting, it returns true, and as I put the send method in a while boucle to be sure he'll be sent (it stops when he's connected to the server), it keeps spamming me the connection.
Is there a more reliable method than that?
They are right as long as they have a pretty bad bandwidth
If I run a bandwidth intensive application (i .e. discord) on my 16 kbit/s connection the latency can go to up to 2 minutes where as usually it would be at under 6 seconds
However in their case reducing the bandwidth via proxies is going to make more harm than good
Why does it only execute "1" and not "2"
@EventHandler
public void onRightClick(NPCRightClickEvent e) {
Player player = e.getClicker();
NPC npc = e.getNPC();
player.sendMessage(ChatColor.RED + "1");
Human human = NinjeHuman.getInstance().getHumanManager().getHuman(npc);
player.sendMessage(ChatColor.RED + "2");
}
public Human getHuman(NPC npc) {
for(Human human : getHumanList()) {
if(human.getNPC().equals(npc)) {
return human;
}
}
return null;
}
Because God has decided it doesn't
The reason it doesn't is because there is an error in your code
You can keep posting the same thing over and over again but the answer is the same
Yea I know that something is wrong, but I'm not sure why that's why I am posting it
Have you tried removing the Human human and seeing if it works? If it does then you know you've get an error somewhere.
You've narrowed it down so to speak
Run a debugger on it
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yea I already knew it was something to do with the Human thingy that's why I had it there 😄
Throw a log in the for loop
Does humanList return null
etc etc
Log actually useful info not 1,2,3,4 in case you've got those somewhere else
Yea, I just did 1,2 cuz I didn't know what to check
Got it working, thanks
does anyone know how to place an item in a chest in a specific row and and column in the chest
this is what I got so far
loc.getBlock().setType(Material.CHEST);
Chest chest = (Chest) loc.getBlock().getState();
Inventory inv = chest.getBlockInventory();
chest.getInventory().clear();
inv.addItem(new ItemStack(Material.STONE, 2));```
?jd-s
cant find it
declaration: package: org.bukkit.inventory, interface: Inventory
?!??!?!
?
?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.
Stop copy pasting, check the docs
pls help
Hello ! i try to change a block client side for a player
i used Player#sendBlockChange but all player see the block change
it's very weird
Well that's literally not how that method works 😛 If you called Player#sendBlockChange(), only that player will see the block change
it's weird
So unless you did,
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendBlockChange();
}```
That's not the case
I know, and that method does that
but the only case where all players would see it is if you did it in a loop
show your current code
yis. c0d3 pls
c0derinho
any1 here work with Crunch before by redempt?
block5.setType(Material.AIR);
player.sendBlockChange(new Location(Bukkit.getWorld("world"),1386 ,4 ,1513),block5.getBlockData());```
?paste it too so it doesn't look like a word salad
I mean, all relevant code would be helpful because that on its own looks fine
are you 100% sure it's really not in a for loop?
yes yes
Actually no, it isn't lol
hm I would check it out myself, but mojang now forces me to migrate all my alt accounts
You're setting it to air then displaying to the player that you set it to air
so I can't
i use worldguard event plugin on regionenter
Block#setType() = server, all players are going to see that air change
Do i need to set the players PDC back after changing it?
you send a blockchange to the player with the material the block already has
no
k
i will create a new block
well currently you get the blockdata of XYZ and tell the player "block XYZ now is the same as block XYZ", nothing would change
am I the only one who can never remember this property name? ${settings.localRepository}
So I am trying to include a webhook receiving something, but when I test it I get this error ��{"translate":"disconnect.genericReason","with":["Internal Exception: io.netty.handler.codec.DecoderException: java.io.IOException: Bad packet id 79"]} I was told it was an MC related issue so that is why I am here. :P
does any1 know how i can map a range of values to another range of values?, ik this isnt rlly spigot help but im shit at math
for example 1-100 & 100-1000, if i had an input of 50 that would be 500 i think
How can i equal an enums value to the next of iterator
Just use == with your enum entry...
I have a static block that isn't running when my plugin loads, or ever for that matter. All it does is first print a line and then register something to a map. Do static blocks run normally on a spigot server?
question is there a way you could let users create private worlds through your server with their own mods/plugins and have it be connected to your main server?
Yes. They are ran when the class is initialized.
does something special have to happen for the class to be initialized?
Sure with quite a bit of work you can do that
It needs to be touched
public class Staff {
private String name;
private Ranks ranks;
public Staff(String name, Ranks ranks) {
this.name = name;
this.ranks = Ranks.STAFF;
}```
i have this
cool
Staff p = new Staff("A GUY", Ranks.STAFF);
ListIterator iterator = list.listIterator();
p.getRanks().toString().equals(iterator.next());
System.out.println(iterator.next());```
So with a bit of coding I can? K I will publish the code when It's done
You will need more than just code. You need orchestration and a stable backend. For this to work you need to write some proxy code
orchestrate docker containers and much more. This is not a single project. You need to properly design a custom solution for that.
im good at making projects, so its not a Problem
@lost matrix what about enums?
Why would you want to have a static block inside an enum?
haha no, like what about the variables in an enum
and the constructor
i mean like
do enum values all get initialized immediately?
When the enum class gets touched. Im not sure this is done immediately.
how do i make it so when u click on a message "are u sure? [yes] [no]" when u click on [yes] or [no] it makes u execute a command
?jd
Isn't ItemStack can be casted to CraftItemStack whenever?
wtf is this?
java.lang.ClassCastException: org.bukkit.inventory.ItemStack cannot be cast to org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
It's exactly what it says it is
No ItemStacks work differently. Use CraftItemStack.toNms() or something like that
CraftItemStack extends ItemStack, yes. So you should be able to cast an ItemStack to a CraftItemStack
yes I think so but failed to cast
I've did it
(newItem as CraftItemStack).handle (I made handle to public)
What platform are you using? It should theoretically work on anything that uses CraftBukkit.
I don't know how it works in 1.12, it's a hundred years old, but in 1.18 you can just directly cast it:
CraftItemStack obcItemStack = (CraftItemStack) bukkitItemStack;
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/command"));
player.spigot().sendMessage(message);```
how would i put a string before it?

Use a ComponentBuilder
Hmmm It's kind of weird.
how?
I've sent you a link above
Here's my class that sends a message including some links, maybe it helps -> https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker/blob/master/src/main/java/com/jeff_media/updatechecker/UpdateCheckerMessages.java
check out lines 133+
Required type: BaseComponent[]
Provided: ComponentBuilder
show your code
BaseComponent[] component = new ComponentBuilder(Color.translate("Hello "));
oh
you can also just get a List of Components
then create an empty TextComponent and use addExtra like in the class I've sent above
then how would i concat them?
lines 133+
I am simply creating an empty component, then append all my other components that include links or not in a for loop
using addExtra on the original component
i couldnt do it
Show your code
sh0w y0ur c0d3
How can I check if a command has none arguments? Can't get i to work
some people use camelCase, real programmers use sPoNgEbObCaSe
Staff p = new Staff("A GUY", Ranks.STAFF);
ListIterator iterator = list.listIterator();
p.getRanks().i == iterator.nextIndex();
System.out.println(iterator.next());```
what does it print? what is it supposed to print?
WE SHOULD JUST ALL CODE IN UPPER CASE
BUT HOW WOULD WE USE ENUMS
Hi guys what Chat API do you recommend?
Bungee
i want to equal the Ranks.STAFF's entry to iterator's new index
MYENUM.NAME ofc
nonono MYENUM.name would be better
the builtin one
that's also nice
Can someone please help me? https://www.spigotmc.org/threads/cant-connect-to-phpmyadmin.550738/
why doesnt if (args.length == 0) work?
it works
it does if the command has no further arguments
Not for me
then you're using it wrong
@tender shard
if its just "/command" passed in it works
connect to phpmyadmin? what do you mean? phpmyadmin is just a web applicatino
if (cmd.getName().equalsIgnoreCase("feed")) {
if (args.length == 0) {
player.setFoodLevel(20);
player.sendMessage("You have been fed");
}
}
that does work
not in method
well then show more code, the error must be above
also why are you checkin the commands name?
SQL
mySQL
package me.northymc.testplugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlayerCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("§cThis command can only be executed by players!");
return true;
}
Player player = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
// FEED COMMAND
if (cmd.getName().equalsIgnoreCase("feed")) {
if (args.length == 0) {
player.setFoodLevel(20);
player.sendMessage("You have been fed");
}
}
return true;
}
}
theres some tutorials which show people to do that
sadly
you already use args[0] before checkin if there are any args
so it throws an error
The problem i have with BungeeChat API for TextComponents it say is Deprecated
What else can I do?
and to be honest you could have showed us that error in the first place
you dont need to check the name
you have to declare it in the plugin.yml tho i think, did you do that?
So
Player target = Bukkit.getPlayer(args[0]);
should be below the if statement?
you basically do this:
- Yo, player is the first entered word
- Were there any words entered? If no, heal the player from step 1
This makes no sense
Inside*
You want to declare Player target = null. Then check if there are any args. If not, cast the CommandSender to Player and store it inside target. If there any args, get the Player with that name and store that inside player. Now heal the player
your logic should probably be something like if(args.length == 0) target = sender;
weird, why would anyone ever do that
is there a way to test Listeners?
How can I make a method for ChatColor.translateAlternateColorCodes so I don't have to type it every time?
is it possible to save the contents of a guava multimap to a file?
You are essentially asking "how to write a method"
Sure
*as long as they can be serialized
Basically yeah, but maybe this is the wrong place. I doesn't understand methods that well
Just forget it
Gotta learn java if you want to write plugins
public static String replaceColors(String input) {
return ChatColor.translateAlternateColorCodes('&', input);
}```
Spoonfeed
You asked for it?
bruh
Yes, but I want to undestand what is happening
literally nothing happens
Better off googling how methods work then
What is the purpose of this? What even is the content of "list" paint a bigger picture
Tho to elucidate methods, they're just instructions which can be called whenever you want in principle
that moment when the method name length is the problem, but its not even that long XD
when ur method name is longer than the code inside
I want to equate p.getRanks with the current iterator
lmao
Im thinking this is a xy problem. So explain what the list contains and why the iterator exists in the first place
I'm stuck on something, when I open an inventory, I can still take stuff out of it even when I set cancelled to true in InventoryClickEvent
ArrayList<Ranks> list = new ArrayList<>();
list.add(Ranks.MEMBER);
list.add(Ranks.TRIAL);
list.add(Ranks.STAFF);
list.add(Ranks.FOUNDER);```
Nope. If its cancelled then you cant take items out.
lemmie show u
how do you explain to somebody stealing code is worse than learning to code it yourself
sounds self explanatory
I did
e.setCancelled(true)
}```
and I can still take stuff out of it
you dont. They learn or they die.
then the event's inventory doesn't equal inventoryName
which makes sense since inventoryName probably is a string
Make it a
EnumSet<Ranks> memberRanks = EnumSet.of(
Ranks.MEMBER,
Ranks.TRIAL,
Ranks.STAFF,
Ranks.FOUNDER
);
And instead of going through every single element you simply do this:
private boolean isMemberRank(Staff staff) {
return memberRanks.contains(staff.getRanks());
}
Inventory name is an inventory
okay but then it's a different inventory
Inventory inventoryName = Bukkit.createInventory(null, InventoryType.CHEST, ChatColor.GREEN + "" + ChatColor.BOLD + "Crates");
Put a debug massage in there. Im guessing that it doesnt get cancelled.
k
what debug messages do you use for your plugins?
Im usually on the
sender.sendMessage("CP1");
or
Main.getInstance().getServer().getConsoleSender().sendMessage("CP1");
train
System.out
I just sout most of the time.
or Main.debug(String)
Logger logger = LoggerFactory.getLogger(Class.class)
where debug is this
public static void debug(String... text) {
if(debug) {
for(String line: text) {
instance.getLogger().warning("DEBUG " + line);
final TextComponent textComponent = Component.text("You're a ")
.color(TextColor.color(0x443344))
.append(Component.text("Bunny", NamedTextColor.LIGHT_PURPLE))
.append(Component.text("! Press "))
.append(
Component.keybind("key.jump")
.color(NamedTextColor.LIGHT_PURPLE)
.decoration(TextDecoration.BOLD, true)
)
.append(Component.text(" to jump!"));
Did anyone know how i can send this textcomponent to player?
Player#spigot().sendMessage()
pülayer.spigot().sendMessage(yourComponent);
Player#spigot#sendMessage
that looks like adventure
quick, we need a fourth answer
yes that is
I just realized @EventHandler wasnt on top of the thingy
Yes its adventure
hm
you should have told us that lol
if you're on spigot
in fact that will work I think
I'm using paper not spigot
use the adventure bukkit platform's BukkitAudiences
mfnalex has a hot voice btw, I heard it yesterday
Hm
ah
Ah
then just Player::sendMessage should work
paper
haha thanks
Then you can just use sendMessage
as it takes ComponentLike, Component etc
Yeah
German voices are the best in the world 
I don't know but it don't work
for Player.sendMessage(textcomponent) is because its not a string
you have to rely on the paper api
Well obviously. Does this component have no documentation?
Do you add paper as your dependency?
Find the docs and read the docs
yeah it's not logging that I clicked inside the inventory
can i convert a guava multimap to a hashmap
Show me your code
sure
from MultiMap<String, String> to Hashmap<String, List<String>>
not sure how tho
I’ll help as possible.
these are mine dependecies:
<dependencies>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.10.1</version>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Before working BungeeChatEvents and Spigot but now no, and i don't know why
ah right ok
Iterate through and copy it into another map
maybe just ask at paper's discord 😛
I mean paper has a discord doesn't it
paper api has adventure as transitive
thus just depending on paper will get you adventure on the classpath
ignore the itemstacks
does .asMap() not work
wait it's already registered
and yes eventhandler is there
Let me check angin.
What is maingui and where you call this function?
Inventory mainGui = Bukkit.createInventory(null, InventoryType.CHEST, ChatColor.GREEN + "" + ChatColor.BOLD + "Crates");
player.openInventory(mainGui);
can you have while (true) in your code or does it break game in minecraft
Yes you can
If it’s not on main thread, that’s normal
okok
If it’s on the game will stucked.
Hey im having this issue were im trying to create a bossbar through the spigot API and set values for the bar ie: BarColor.Blue. The issue is it dosent recognize any of the values im giving it and the bar is always solid and pink, any reason for this?
that's weird, console is saying that there is an invalid event handler
Ok let me change your code to using gui name check instead of equal check.
What
public void onInventoryClickEvent(Player player, InventoryClickEvent e)```
that's where the event handler is
I'm creating an alt checker plugin, what would the best way of storing player ip's and then checking them on login be?
should i just store it all in one json file
To get player
That’s not good way
Your file size will being bigger and bigger.
You can't have multiple parameters in an event handler.
well then whats the good way
why not? as long as he doesn't have 50k players
I’m telling him how to parama.
does anyone know why my code would get stuck: code link https://paste.md-5.net/oyunusezop.cs
and you could also always remove old entries
fr?
I'd give the server admin an option to use either SQLite, JSON or mysql
because you do while(true) lol
You know?
It will uses more time and more performances to save data.
You remove the player parms.
just save it async or on shutdown
I cant get a player from e.getWhoClicked()
but it is not in main thread
it's a HumanEntity, just cast it to Player or return if it's not a player
But you need cast it
oh alr
then it done
AFAIK, the methods don't register properly if there are multiple parameters. Also, I have yet to see a plugin that has multiple parameters in one of their event handlers. Could open up some possibilities if it worked like that.
where is it then? You're accessing API, so itt can't be async
If there still nothing log, you need change your check way.
runTaskTimer (new class)
that's not async so you can freeze the server there
Hey
how would I change it then
remove your weird while loop
Why you need to use while?
I still can get items from the inventory
I need to check if the space is clear though, and if it is not, i pick new location
and why do you need to keep repeating that forever and ever and ever (while true) ?
Can you explain it more clearly?
You could just use a for loop.
What do you want to do
if (breakFree) {
break;
}
Hm
it should break out on line 75 if all the perameters are met
Wdym
Queen vibes intensify
What the result you want
I want to check if a specific spot is available, if it is, it will break out, and if it is not it will pick a new spot
you never set it to true in your loop
move the breakFree = true into the loop
at the top of it
are u sure that will change anything
Hm
that is just writing it difrently, (writing it better)
no i am not sure if this fixes it, the whole code is totally cursed
