#help-development
1 messages · Page 330 of 1
um
I kinda like terminal UIs for that reason
did anyone figure out what is wrong in the code i pasted?
this is what I currently had made
I think the most efficient way for doing this outline would be using Packets, so then only the client see them
and the more i look it the more I hate it
how do i use packets?
use the spigot api
it only works in the origin chunk
nope.
what?
In chunk 0/0/0 I mean
?????????????????????????????????????????
You are working with absolute values
wtf it does
I.e.
player.sendBlockChange(new Location(playerWorld, 15, highestBlockInChunk, i), blockData);
is wrong as x,y, and z won't ever be beyond [0,255]
for x, z it's even worse with them never being beyond [0,15]
enter 1.18
wait.................................
oh.........................................................
nevermind
i am tired today.......
so you understood your issue?
iirc block limits are not hardcoded anymore
what's so special about that one?
i thought they were chunk coordinates
Ah you mean THAT
-64 is the lowest point
Like I want to use the world gen on startup then wait until i'm allowed to create worlds and create the worlds @tender shard
bruh
i am blind
so
blind
lol!
i somehow thought i was working in chunk coordinates and relative to the chunk of the player even though that is clearly not the case.
chunk coords are doesnt have y value
x,z only
no they do, blocks in a chunk
since chunks are mapped into 2d
Even then they are in world coords
in the f3 screen.
I thought it was more efficient, because the sever doesnt have the extra load for rendering
As far as i know client rendering is more efficient rather server rendering
unless you are using cubic chunks mod
Well it's complicated
blockchange literally just sends the packet
There are Chunks sections and Chunk columns. Both can be considered to be "Chunks"
oh ok that only happens on newer versions that why hahaha
It happens on all versions
Yeah that why i was confused as far i used to code on 1.8
you needed to get the nms network manager and get the packet class to send it manually
Also dont you need the player handle?¡
you do
that's how you get network manager
or smth like that
i havent coded plugins since august
i've been busy with uni c++
and assembly, bitwise operations 😄
oh ok, dovidas dont you know which class listen RemoteQuery from Bungee?
no idea
Because on bungee its like a RemoteQuery object which make queries to Spigot side, but i dont find it on the bukkit code
assembly ¯_(ツ)_/¯
i had to suffer with writing the instructions in binary
i had it too
player.sendBlockChange(playerChunk.getBlock(i, highestBlockInChunk, 0).getLocation(), blockData);```
fixed the error
most useless lecture ever
i just copy pasted code and it has cost me like 40 mins
java bytecode would've been more useful in my case
asm is powerful, but it takes time
lmao.
hmm
JVM is written in C++ right ? And internally performs ASM operations
C
oh kk
JVM is written in C and yes, you're right kinda
Im really confuse with ASM because there 2 ones
Hey, I need a little bit of help with attack cooldowns. I am trying to get the exact time in ticks of the attack cooldown of the player.
For instance, if they player were to swing a sword that takes 1 second for the cooldown to go away, it would return 20. If you were to use the default .getAttackCooldown() It only returns a number between 0 and 1.
C is more raw, and C++ is more versatile but at the same time very inconsistent since it wraps around C language principles
myeah, no.
You should ge tthe item stack object and then use they addEnchant method
Depends, if it is for a player then this could work.
player.getInventory().getItemInMainHand().addEnchantment()
but there are structs
I am trying this:
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta meta = item.getItemMeta();
item.setItemMeta(meta);
if(getConfig().getString("espada.display.Name").equals("")) {
meta.setDisplayName(getConfig().getString("espada.display.Name"));
};
if(getConfig().getList("espada.display.Lore") != null) {
List<String> lore = new ArrayList<>();
lore.add("Linea 1 del lore");
lore.add("Linea 2 del lore");
meta.setLore(lore);
}
meta.addEnchantment(Enchantment.DAMAGE_ALL, 1);
you cant add functions in to them
But addEnchantment is in red
no, when i create the item
then you would have to schedule a task that waits until ServerLifePhase is == RUNNING
it is meta.addEnchant
Are you spanish or portuguese?
ahhhh, ok
spanish
Oh rgiht i asked because my native lang is spanish haha
You will also have to pass in another argument specifying whether or not it will ignore level restriction.
ok, thanks
most of the people not realizing the lore doesnt need to be a mutable list
You can overload funct in c?
I mean I would not consider function overloading a feature in c, but there are... well... other ways to achieve similar results
void foo(int a)
void foo(int a, int b)
There is nothing wrong in doing it in c
Afaik that is overloading
Does C have function overloading?
Function overloading is a feature of Object Oriented programming languages like Java and C++. As we know, C is not an Object Oriented programming language. Therefore, C does not support function overloading.
maybe your compiler supports it?
isnt overloading the same method with dif amount of params?
i never use all those fancy words, i just know how to impl stuff
the same method with same parameter counts but different types
c does not support polymorphism which is why you cannot do that in c
for example
void foo(int param);
void foo(char param);
you can't do that
I can swear Ive done that for my school project
as long as the function name is the same you cant do it
you can do this however, and you see this often in c
void foo_i(int param);
void foo_ch(char param);
c++ is object oriented and supports polymorphism
lets goo brr...
C++ can overload functions but internally it uses function naming map
its kinda hacky
and very barebones
🥲
overloading is syntax sugar anyway, when it comes down to it and you boil all the way down, it has to do fucky shit
it is what it is
i still dont get it why C++ compilers read functions as two distinctive ones even if the names are the same, but still do some suffixing for no reason, since asm use pointers to call functions not their names
not a clue, im not a c++ user :p c however is bae
i bet it has to do something with C backwards compatibility
that probably makes sense. valid c is valid c++ right? so g++ probably is indeed compiling it the same way as gcc would
but pure guess
mostly
*(void*)var is invalid in C++
while it is valid in C
afaik
and this is why i don't like c++
illegalizing my beloved pointer hell
afaik g++ has a flag to set to either compile it for C or for C++
if you do man g++, it pulls up the same document as man gcc. so i think they're the same program - the manual merely mentions that some flags are for c++ only and when used on c have no effect
it also says that when compiling c++, you could use gcc, but g++ should be used as a matter of habit
im wondering what one im actually using
no clue i have them both and i forgot which one to use on cli
Hey when yall finish ping me i wanna ask a qustion i won't disturb yall
g++ ig
aight
so
I'm trying to make a small annotation based commands system core for my server i've made a good progress so far but i' having issues while registering the commands (actually i'm not facing any issues but i have no idea how to register the SubCommands for the root command using annotations).
My idea was to make a SubCommand Object and load it from the annotation @SubCommand then add them to the subcommands list at HomiesCommand Object.
All i need is some expert to guide me how to make it happen
Command Manager:
public abstract class HomiesCommand extends BukkitCommand {
private List<HomiesSubCommand> subcommands;
public HomiesCommand(String name, List<HomiesSubCommand> subcommands, List<String> aliases, String permission, String permissionMessage, String description) {
super(name);
this.setUsage(MessageUtils.format("&cUsage:/"+name));
this.setAliases(aliases);
this.setDescription(description);
this.setPermission(permission);
this.setPermissionMessage(permissionMessage);
this.subcommands = subcommands;
hook();
}
public void hook(){
Field field = null;
try {
field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
field.setAccessible(true);
CommandMap commandMap = (CommandMap) field.get(Bukkit.getServer());
commandMap.register(getName(),this);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@Override
public boolean execute(CommandSender commandSender, String s, String[] strings) {
if(strings.length > 0){
for(int i = 0; i < this.subcommands.size();i++){
subcommands.get(i).execute(commandSender,strings);
}
}
execute(commandSender,strings);
return true;
}
protected abstract boolean execute(CommandSender sender, String[] args);
}
SubCommand annotation:
public @interface SubCommand {
String value();
}
Command annotation:
public @interface Command {
String value();
}
ig you need some kind of Map<String, SubCommand> to keep track of them and to select the one to call
i'll try to check later if you can't figure something out. but there are a few annotation command libs existing, you could reference them to see how they do it. ACF & Cloud come to mind. but brush's idea doesn't seem bad
im wondering what that abstract method is for
i've tried ACF tbh i didn't understand a single example how to use it
their wiki is shit yes
i was trying multiple ways so u might find some extra useless things
i've tried something else
so wait each subcommand is a bukkitcommand on its own?
1s lemme send the code
i kinda stopped messin with making my own command framework cuz it always ended up as a mess
each command is a BukkitCommand i wanna add the subcommands into the custom command i made
@Getter private static CommandAdapter handler;
public CommandAdapter(){
handler = this;
}
private final Map<String /* SubCommand Name */, Method /* SubCommand Execution */> subcommands = Maps.newHashMap();
public void process(Object object) {
String name = null;
List<String> aliases = Lists.newArrayList();
Permission permission = null;
Method commandFunction = null;
for (Method method : object.getClass().getDeclaredMethods()) {
if (method.isAnnotationPresent(Command.class)) {
Command command = method.getAnnotation(Command.class);
name = command.value();
commandFunction = method;
for (String alias : command.aliases()) {
aliases.add(alias);
}
}
if (method.isAnnotationPresent(SubCommand.class)) {
SubCommand subCommand = method.getAnnotation(SubCommand.class);
subcommands.put(subCommand.value(),method);
}
if (method.isAnnotationPresent(Permission.class)) {
permission = method.getAnnotation(Permission.class);
}
}
Method finalCommandFunction = commandFunction;
HomiesCommand homiesCommand = new HomiesCommand(name, aliases, null) {
@Override
protected void execute(CommandSender sender, String[] args) {
try {
finalCommandFunction.invoke(this,sender,args);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
};
if(permission != null){
homiesCommand.setPermission(permission.value());
homiesCommand.setPermissionMessage(MessageUtils.format(permission.message()));
}
PluginManager.getInstance().register(homiesCommand);
}
this where i tried alot of shitty codes to make it work
and never did
uhh
idk what i was doing tbh i tried evreything i could to make it work
i'ma recode this one
any tips ?
cuz idk how the params of the invoke() method works
it takes in the parameters of that method
aight cool
so for each subcommand i think i'll let it take the CommandSender and String[] for arguments
but i have a qustion
what if the subcommand have to be smth like a player name
how can i define that
I guess player name will be always parameter for example /command <playername> subcommand, so in that case you need to make system that will treat second parameter as subcommand
so like a placeholders for some of the subcommands ?
Ye like each command could have list of arguments <Name,Type>
can u explain more cuz i've been working on this for like 8 hours now i'm losing my focus
i just tried smth rq but its about as what you have lol
can u send me the code i might get inspired from it
Are you building this command system for sake of learning or to improve plugin?
both i wanna improve my skills with annotations & i'll use it in a simple core for my server
https://www.spigotmc.org/resources/api-commandapi-1-13-1-19-3.62353/ in case not wasting time use this library
in case of learning
w8 a moment
looks like brigadier
i think i'm going to fix it
How can I make my own player object that also works as a Bukkit player
If I extend I need to implement all methods, is that the correct way?
https://paste.md-5.net/osodosogol.java
trying to make a plugin with a custom configuration file where when a player joins the server, it logs their uuid along with a trample value of true. the plugin should append a uuid when another player joins as well. though when i restart my plugin and rejoin on the first account, all other entries are gone. how do i prevent this?
do you really need to create a different impl or do you just a player wrapper?
Hmmmm
I need to add some stuff to a existing player
Fields specifically
Like, lives, killcount, etc
i just created a wrapper which wraps a player uuid and adds playerdata my plugin uses
That would be great to have something to go on
Thanks! Much appreciated
Why use playerdata in that case tho
i can't send pictures ?
What's the difference between adding all that to KindgomPlayer
more organized than just throwing a bunch of maps in my player wrapper
it probably had other reason too, i believe it was wrapped in a AtomicReference<T> in the first case too but i removed that
I see
But technically
Everything in both classes
Is accessible by any of your kingdomplayers
So it would be the same thing putting it in 1
yes
idk why i can't send pictures here is a link of it instead
?img
Not verified? Upload screenshots here: https://prnt.sc/
same link whatever
i think i need to register each sub command into a map or smth that takes @SubCommand as a key and the method of it as a value
so i can call invoke using @SubCommand object from the subcommands list
Fourteen
what do u think guys
{
public interface CustomCommand
{
boolean invoke(CommandSender sender, String[] args);
String getName();
List<CommandArgument> getArguments();
List<CustomCommand> getSubCommands();
}
public interface CommandArgument
{
String getName();
ArgumentType getArgumentType();
}
public enum ArgumentType
{
NUMBER, TEXT, PLAYER, COMMAND
}
}``` You can take this approach, so when argument type is set to `Command` you check in subcommands contains provided value and trigger it
ps subCommands list should be private
anddd how can i register the command using this way ?
w8 my brain lagged
reflections my friend
So i'm trying to make this:
Game.class ->
- Contains stuff like
- Game state
- Level
- GamePlayers
GamePlayer.class ->
- Contains stuff like
- KillCount
- DeathCount
- etc
If I want to include something like you did Bossbar in GamePlayer.class
How can I read what level i'm on from Game.class since it's being stored there
the last two cells just broke
make some fancy method like addArgument()
Do I need to make a absract class that's parent to both game.class and gameplayer.class?
what
an argument
?
like /sethome <name> where name would be an argument with type STRING
then what is the use of getSubCommands();
well right, this should not be public but private
This plz before it gets lost
can u put it in a small exmaple i'm sorry but i can't under stand how will this work i'm tired of testing my brain broke
but you need to keep all avaliable subcommands in list inside command class
here is my class understand how it works then try to make a similiar one
@Getter public class Homie
{
private final UUID uniqueId;
private final Player player;
private final String name;
@Setter private Clan clan;
//private Group group;
private int globalKills, globalDeaths, globalBlocksPlaced, globalBlocksBroke;
public Homie(UUID uniqueId){
this.uniqueId = uniqueId;
this.player = Bukkit.getPlayer(uniqueId);
if(this.player != null){
this.name = player.getName();
}else{
this.name = Bukkit.getOfflinePlayer(uniqueId).getName();
}
this.globalKills = 0;
this.globalDeaths = 0;
this.globalBlocksPlaced = 0;
this.globalBlocksBroke = 0;
load();
if(ClanManager.getBy(uniqueId) != null){
this.clan = ClanManager.getBy(uniqueId);
}else if(ClanManager.getByModerator(uniqueId) != null){
this.clan = ClanManager.getByModerator(uniqueId);
}else if(ClanManager.getByMember(uniqueId) != null){
this.clan = ClanManager.getByMember(uniqueId);
}
HomiesCore.getPlugin().getPlayerManager().register(getPlayer(),this);
}
public void sendMessage(String msg){
getPlayer().sendMessage(MessageUtils.format(msg));
}
public boolean hasClan(){
if(getClan() == null){
return false;
}
return true;
}
public void load(){
try{
ResultSet set = HomiesCore.getPlugin().getDataProvider().getResult("SELECT * FROM players WHERE UUID = '"+getUniqueId().toString()+"'");
while(set.next()){
this.globalKills = Integer.parseInt(set.getString("kills"));
this.globalDeaths = Integer.parseInt(set.getString("deaths"));
this.globalBlocksPlaced = Integer.parseInt(set.getString("blocksPlaced"));
this.globalBlocksBroke = Integer.parseInt(set.getString("blocksBroke"));
}
}catch (SQLException e){
e.printStackTrace();
}
}
}
How can I read what level i'm on from Game.class since it's being stored there
whats that supposed to mean?
ig you need to read properties from that other class?
ig let game store a map<gameplayer, gamedata> or smth
Game contains gameplayers but I need to be able to acces game property
Oh you’re saying do it from the game class
ig ye
Isn’t making a parent class for both better?
so CustomCommand should contain the command and the sub commands right ?
And adding all the fields that must be shared there
Is that good practice?
Like an interface I believe
or create some class extending game player which stores additional session bound data for the game
i feel like an idiot sorry guys i'm not understanding
if anyone does can u put it in a example so hopefully i would understand
keep in mind i still want it to be based on Annotations
to avoid ton of if else statements
private List<CommandArgument> arguments;
private List<CustomCommand> subCommands;
@Override
public boolean invoke(CommandSender sender, String[] args) {
var index = 0;
for(var argument : arguments)
{
var value = args[index];
if(argument.getArgumentType() == ArgumentType.COMMAND)
{
var subCommand = subCommands.stream().filter(c -> c.getName().equals(value)).findFirst();
if(subCommand.isEmpty())
{
//sub command not exists
return false;
}
var subCommandArgs = new String[0];
return subCommand.get().invoke(sender, subCommandArgs);
}
index ++;
}
return false;
}
public void addArgument(CommandArgument argument)
{
arguments.add(argument);
}
public void addSubCommand(CustomCommand command)
{
subCommands.add(command);
}
}```
here example that handle Argument type of COMMAND

yo
What's your opinion on this?
Both extending an abstract class and put the fields I need in both of them there?
what fields do you need tho?
well gamestate belongs in the game class
id just make a map of gamestats objects against gameplayers
a player should not be aware of the game level, if it really needs it for some method, pass it in with dependency injection
No but like "Level 1"
game state*
it just doesnt make sense to put it in a player class cuz if the player leaves the game, those stats dont make sense
But if they leave the game then just delete his player object
But in the middle of the game I need to be able to update stuff for the player as he progresses
ah i thought you needed it for non game related things too
What if I wanna do sendmessage you're on level #
Can't get the level# cause it's in the game class
I think abstract class is the right thing here
I think*
ig you can store the level in the player class then, did that too
but not the gamestate or smth
those are classes
Like, when I create a game and it calls the absClass the data will be different for each object
For each game object*
Wait ignore that I figured it out in my head
and** List<CustomCommand>** what CustomCommand should be the one like i sent earlier ?
this one
?
yes
also it depends how far you want go with subCommand because in your implementation you can't make /command subcommand subsubcommand
aight cool and how to hook the annotation into it by calling a new "FancyCommand"
oo
Hello, i have two questions!
1 - Is it possible to change the skin of a player (if yes can you give me some docs or things that can help me with it)
2 - Is it possible to :
Assume there is a player A and B and C
And there are two skin 1 and 2
Player A will have a skin between 1 and 2 depending on the player looking at A
If B is watching it will be skin 1 but for C, A will have the skin B
(KInda hard to explain, I hope you understood)
u have to use NMS
i guess i did understand the code but i still don't know to which object should i hook the annotations in the CommandProcessor
package mc.homiesbase.com.handlers;
import com.google.common.collect.Lists;
import lombok.Getter;
import mc.homiesbase.com.annotations.Command;
import mc.homiesbase.com.annotations.Permission;
import mc.homiesbase.com.annotations.SubCommand;
import java.lang.reflect.Method;
import java.util.List;
@Getter public class CommandProcessor {
@Getter private static CommandProcessor handler;
public CommandProcessor(){
handler = this;
}
public void process(Object object) {
List<String> aliases = Lists.newArrayList();
for (Method method : object.getClass().getDeclaredMethods()) {
if (method.isAnnotationPresent(Command.class)) {
Command command = method.getAnnotation(Command.class);
for (String alias : command.aliases()) {
aliases.add(alias);
}
}
if (method.isAnnotationPresent(SubCommand.class)) {
SubCommand subCommand = method.getAnnotation(SubCommand.class);
}
if (method.isAnnotationPresent(Permission.class)) {
Permission permission = method.getAnnotation(Permission.class);
}
}
}
}
bump
Can I make a method in DungeonGame that allows me to get the value of a field from DungeonGameHandler from DungeonPlayer?
oh well so quick question would you consider case /command subcommand subsubcommand subsubcommand?
you have to register the DungeonPlayer in the DungeonGameHandler so you can access the DungeonPlayer methods
ye
It is
i wanna use it as a Main Command system
But that's not what I want to do
for multiple arguments
Is there a doc for it ?
tbh i've done smth like this before like a year i don't think i still have a doc for it
Bruh 😅
with annottation that would be pretty painfull IMO, that's way people use Builder design pattern to make commands instead of annotations
and i'm trying to use my last brain cell to understand this
i mean i wanna use the annotation system to avoid tons of if statements
@drowsy gust https://github.com/Despical/CommandFramework
i just need to understand the idea how would i register each subcommand and it would be easier
Go read how he does it
ty
Is it possible to set the latency / ping of a player?
to increase it or reduce it ?
Increase
and mostly no because it has client side things
i have 0 experience with networking i can't help sorry
hello !
Someone knows how to translate the unicode to the icon in TabComplete ?
it shows like : /ue0003 :(
It's ok
Found some sort of doc 😅 https://nms.screamingsandals.org/1.19/
How can I access a field inside DungeonGameHandler from DungeonPlayer?
DungeonGameHandler has a list of DungeonPlayers.
For example I want to access that state field you see in the image from the DungeonPlayer
well youdneed a reference to the dungeon handler
Is that better than making another class that is parent to both gamehandler and player?
Like sort of this
wlso how did you make those diagrams, can intellij generate those 😮
i would say it depends on the field but generally making these endless handlers gets annoying
A gameHandler has a list of dungeonplayers. Those players all belong to the same game
like for example what field do you need
like maybe it would just be fine to pass the dungeon handler to the player constructor and have it be a property of the player
Hmmmm
then you can just do player.dungeon.level
wait no you mean I would do
dungeonHandler.getLevel
Man that feels like a bad structure idk why maybe Im overcomplicating it
in game development you need one class that knows everything which is normally the environment
f.e. world or in your case the dungeongame
store the players there and get them by it
i wouldnt do a handler
well in your case it feels like level should be in player
No because a game can only have 1 value for level
player shouldnt know that any handler or whatever exists
Ok so yopu're saying god
This structure is better
And make methods to access
Arrow means extend btw not sure if everyone knows that
DungeonGame is also a abstract class
Why
why is the Player a dungeongame
I need method declarations
but then its just a glorified version of what I said
or am i understanding something wrong
Yeah it's not cipher I just wouldn't know how to do it
Nono you're right actually
That's wrong
composition over inheritance
player is not a game, it has a game
you need to know what info the player needs and how they get it
Wait give me 2 mins to change the diagram
merge game and handler and voila, you have a central point for your stuff
Isn't that the same as just removing dungeongame
yes
most likely
dungeon game in this example serves no purpose
just that dungeongame is more speaking than "handler"
Ok good i'll remove that
Now once again, how can a player get a field from the DungeonHandler
Does it have to be passed a parameter?
Only way>?
in my plugin the game there can only be one of my game so I just get it like a singleton, that way I can access it from everywhere xD
what exactly are you trying to get
I'm adding a int level
to Gamehandler
Because the level is the same for every players
Like a team game of sorts
what does the player do with this value
All move together
Display it
In a fucking bossbar
LMAO
All for a bossbar
I just remembered why I needed it....
Been at this for 30 minutes...
so why is the player the one that keeps the bossbar
why would your game player need it then?
I would make it so the dungeon ahndler actually pusher bossbar updates to all gameplayers
and any data from player to the handler can be done using events
if even
Alright so lastly
i would seperate that
having a bukkit scheduler which does that and accessing the game
How do I make DungeonPlayer have Player methods tho
wdym by player methods
or give the dungeonplayer a uuid
it would have dungeonplayer methods
so you can access his bukkitplayer at any time
Is it not better to have DungeonPlayer also be a Player?
and a dungeon player can get the actual player in some way
Then I could use DungeonPlayer for like even DungeonPlayer.sendMessage
well you cant do that easily
You're saying add a getBukkitPlayer(DungeonPlayer) type of stuff
no
no im saying that your dp could hold internally his own player instance
your dungeonplayer class needs a way to get the player that belongs to the dungeon player object
and then any actions from the handler to the player should be going through the dungeonplayer
So maybe merge playerdata with dungeonplayer and add Player player as a field
is this class scheme from Intelij?
how to open it? or it's only premium intelji feature
I mean to be conpletely honest imo playerdata is redundant and could be inside dungeonplayer
but thats up to you
better to have it then not
i would rather have my dto extra than transient everything in terms of jdbc
also its a nice seperation
in terms of what?
saving the data
public class DungeonGameHandler extends DungeonGame {
int dungeonGameID;
Difficulty difficulty;
State state;
List<DungeonPlayer> players;
public class DungeonPlayer {
private Player player;
private final PlayerData playerData;
private final transient BossBar levelBar;
public DungeonPlayer(Player player) {
this(player, new PlayerData());
}
}
isnt your gamestate in the dungeongame?
meh fair enough
private int killCount;
private int deathCount;
private boolean isAlive;
private int lives;
public PlayerData() {
}
}
Is that too badf
Yes
Oh wait never changed that
playerdata should only be data and not a state like isAlive
yes exactly thats what I would put into the dungeonplayer
any why is your dp holding a bossbar
but like are these values just for one game or like a scoreboard thing
Wait wait 1 min fixing all
public class DungeonGameHandler extends DungeonGame {
int dungeonGameID;
Difficulty difficulty;
State state;
List<DungeonPlayer> players;
public void addPlayer(DungeonGameHandler gameHandler,Player player) {
players.add(new DungeonPlayer(gameHandler, player));
}
}
public class DungeonPlayer {
private Player player;
private final PlayerData playerData;
private final DungeonGameHandler dungeonGameHandler;
public DungeonPlayer(DungeonGameHandler gameHandler, Player player) {
this(gameHandler,player, new PlayerData());
}
public DungeonPlayer(DungeonGameHandler gameHandler, Player player, PlayerData playerData) {
this.player = player;
this.playerData = playerData;
this.dungeonGameHandler = gameHandler;
}
}
public class PlayerData {
private int killCount;
private int deathCount;
private int lives;
public PlayerData() {
}
}
I think that makes sense now
At least to my peanut brain it does
yeah well no
why does your player hold a handler now
why is dungeon game a parent of dungeon game handler
and your addPlayer gets a handler?
Oh true we just said we don't need a handler
i mean the addPlayer method is literally in a handler
also i would rename your handler class to the actual game class
Fair
well yeah I would rename dungeonhandler to dungeongame and remove the old dungeongame as that was empty
whats in your dungeongame class
Yup just did
like he said xD
🦜
Alright I think i finally got the structure down
Thanks for the help and the patience and I apologize
you're welcome
np
Now some extra questions if you're bored of me yet:
All game related stuff goes straight in the dungeonGame:
---> Gamestate
---> Manage the game
---> etc
DungeonGame has a runnable task to check for the game states and do stuff accordingly
---> Does game logic also go in there?
---> Event listeners
And some method to "enable" the game to start the task
if i have event.getPlayer().setWalkSpeed((float) getConfig().getInt("kot.spawn-walkspeed")); and the speed in config is 0.7 it wont let the player move
custom config file resets on restart
public void startDungeon(Player player) {
new BukkitRunnable() {
@Override
public void run() {
if (!isEnabled()) {
ChatManager.sendMessage(player, "This dungeon is not enabled!");
return;
}
}
}.runTaskTimer(plugin, 100, 100);
}
How can I make it to if the condition is not met it stops running repeating tasks until it's called again?
Would cancel() stop the tasks completely?
Ok perfect! Thanks
any idea?
Is posible to disable chest open sound?
I found a method called Entity#setSilent()
i dont think a chest is an entity
it is
oh ok
Has anyone noticed any issue with the Spigot logger? ie not able to set to Level.FINE ?
I set the level to FINE but it doesn't actually show anything I output to FINE
System.out.println("++++++++++++++++++ " + GroupManager.logger.getLevel());
GroupManager.logger.fine("Found an " + result.resultType + " for " + permission + " in group " + result.owner.getLastName());```
No FINE logging for fine
it doesnt use it
it used to
Hi, i use intelij idea and i need to add okhttp to my project (in my pom.xml) but it doesnt work
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.steelfri</groupId>
<artifactId>SteelfriStaff</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SteelfriStaff</name>
<description>Plugin Staff</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>19</source>
<target>19</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
</dependency>
</dependencies>
</project>
this is my pom.xml
did you reload maven?
how ?
on the right you should see a maven tab, open that then press the circle type thing far left of the top of that pane
okk i find it
The approach that I took for this was to implement my own custom IInventory using nms that wraps the player's storage contents and armour contents. It's backed by the exact same list instances, so changes the player makes are reflected directly.
Hey all, how can I make a sort of private world for a player? Sort of how in skyblock each player gets their own little world, I want to do the same here.
What is the best method to handle configs with the newer built in methods supporting comments for both new versions while still supporting old versions? Has anybody made a config manager utility class? Should I not worry about pre 1.18 versions?
@minor shell I have my own FileManager for that. Do you want to take a look
Devs help me out, why would a player hypothetically be pining another a server at the same time as trying to join mine?
they keep crashing but ive noticed in their logs they try pinging 2 servers at the same time
Pining? Do you mean pinging?
Assume this guy was doing something dodgey
cause they didnt even know where logs were
so it might be a "using dodgey thing, but didnt know much about the back end"
Server list in the client pings all servers visible at the time on the client.
Hey
so nothing dodgey?
he had already been able to log on
Ok? Not sure what that has to do with pinging servers in your saved list of servers
Im just trying to figure out why, the day I turn the anti xray on this guy in particular be having issues server side
There is not enough information to determine this. I can only tell you of things that is normal for the client
My plugin is currently getting loaded on startup because it contains a world generation feature.
But I also need to create more worlds, I know I have to wait until the first world is setup. How can I do that from onenable
jeffLib has getLifePhase() but I have no clue where I could add it to
@tender shard jefflib
normally isnt
I know getLifePhase() returns the server state I just don't know where I would call it
declaration: package: com.jeff_media.jefflib, class: ServerUtils
yessir
declaration: package: org.bukkit.event.server, class: ServerLoadEvent
Listen to this event
Anyone got any ideas what cause these funky logs?
There you go exactly what I need
It gets called when the server is finished loading
its colour codes if you mean the symbols
Everything
I mean that the "poor guy gets yeeted 5 secs after joining (2nd pic)"
Also note it is called when reload is used too
Alright afk again. Good thing i popped in when i did 
could be internet issues, if not idk what else would cause that
I think it just hit me ....
they sent me a screenshot of the log
this is a player who doesnt code
.....
JDK 17 is in the background
If that is true its dump
It is true
anyone have any ideas?
For what?
I'm going to guess incompatible hacked client
The jdk includes the jre, it is not bundled seperately anymore.
to run any java application
Okay hear me out, why is it on his desktop?
as in?
Why would you need developer kit to run app lmao
Cause he just installed it and pressed the create shortcuts option? @livid dove
Refer to my previous response.
Exactly....
I understand that, just trying to find some sense there
It’s easier to just bundle it in one place than split it.
I dont think you are quite listening here. This is a player who didnt even know where the logs for minecraft were
Plus java 9+ allows you to bundle a minimal jre in your distributed jars iirc.
So?
He installed java
It is on his desktop
What scenario made him install java?
playing minecraft
He needed to run the server obviously
iirc mc doesnt come with java anymore
@remote swallow it does afaik
Welp turns out he's never owned a private server (he hasnt clocked on i saw the jdk lol)
So erm, alternative theories?
:L
What’s the issue? @livid dove
-Guy cant conntect to server
-Is unable to connect after i turned on the anti xray earlier today
-has the following logs and erm... welll ... yea..... points at the JDK
K. And whah’s the last thing in the logs?
.
Oh, he probably just downloaded it to desktop @livid dove
@livid dove Is the last “Can’t ping” your server ip?
installed with fabric, and added the shortcut to desktop
2 different servers
ours
and a random one
Does his game crash or does it simply go back to his server list.
booted as far as i know
when I say booted i meant server list
other servers are fine
on https://speedtest.net not google
*other servers are fine
Still want to see it.
that means nothing
Which version is he running snd which version are you running? Mc-version
I'll find out in a tiny while
i'll be real guys, only thing giving me pause is the only other guy who has had this problem is a 2b2t player who's had half his group caught for hacking so far xD
so for em both to have the same issue on the same day i turned anti xray on is erm
yeah
xD
Get him to tell you the exact version of his mc. Fabric etc.
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.tomisanhues2.dungeonmaster.Dungeonmaster.getCommand(String)" is null
did you add to plugin.yml
This load: STARTUP is annoying to deal with...
Oh you're right lol
I blame alex for convincing me not to use the framework I was using
icl im with him
And if he's on the lunar client?
:L
that framework looked awful
Tell him to try on a normal client?
lol fair
How can I define a method that would go here
What does that even mean
plugin.getGameList().get(lobby - 1).addPlayer(p).HERE
where
Returns a List<games>
Objects should be named upper case
It's not actually that
im gonna guess that means it adds a player then .HERE means something you do
It is named uppecase
I mean I want to replace .here with
.teleport() and automatically teleport the player too
make the addPlayer method do thant
I thought about that too
Yeah i'll just do that
Was just curious tbh
Like what is it
or add a .teleportPlayers() method that teleports all players
Like just to know. where would a method have to go to be able to add it there
same place you have addPlayer
and make sure .addPlayer returns the instance of that class
Create a wrapper or smth @regal scaffold
If I send my timings report, can someone help me figure out ways to make my plugin more efficient? There are lots of lag spikes
Maybe
@EventHandler
public void onShoot(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (p.getInventory().getItemInMainHand().getItemMeta() != null) {
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Arrow bullet = (Arrow)p.getWorld().spawn(p.getEyeLocation(), Arrow.class);
bullet.setShooter((ProjectileSource)p);
bullet.setVelocity(p.getLocation().getDirection().multiply(4.5D));
bullet.setDamage(5.0);
PersistentDataContainer bulletPDC = bullet.getPersistentDataContainer();
bulletPDC.set(new NamespacedKey(Nebula.getPlugin(), "a8pistol"), PersistentDataType.STRING, "shot");
p.sendMessage("Sent via onShoot event" + String.valueOf(bulletPDC.getKeys()));
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(bullet.getEntityId());
ReflectionUtils.sendPacket(p, packet);
}```
Hey all, this little event checks for when a player shoots with anything rn, but as you can see, im setting the pdc of the arrow to a value of shot, but in a later event when i check if that arrow has a pdc, its empty, any ideas?
It's an arena based pvp duels server. As more players are dueling there are more maps being created so I decided to paste x amount of maps at the beggining so that way there didn't need to be pasting all of the time. But i'm unsure of other ways to lower the lag
TheBridgeServerUtils is sync loading a lot of chunks.
Okay, tested a few things here and added a check for the pdcs existence in this event and it def returns the keys but in the other event, it doesnt..
Tried using metadata instead?
Did some research and fixed some stuff up:
i set the metadata to have a key of a8bullet and in the second event which checks for when it gets shot, i check if the metadata exists but it never passes the if statement so it doesnt:
bullet.setMetadata("a8bullet", new FixedMetadataValue(Nebula.getPlugin(), "a8shot"));
``` First event here
```java
if(e.getEntity().hasMetadata("a8bullet"))```
second event here
just closed my ide, i think it was projectilelaunchevent
@quaint mantle tried using the consumer inside the spawn function?
I need to have lots of chunks loading since there is a lot of arenas
anyone have experience updating a block? I am trying to make all crops grow to max age. I am not seeing anything happen after setting age. trying to update state didn't do anything either
HashSet<Block> nearbyBlocks = getNearbyBlocks(player, 5);
for (Block block : nearbyBlocks) {
if(block.getBlockData() instanceof Ageable ageable) {
ageable.setAge(ageable.getMaximumAge());
block.getState().update();
}
}
block.getState().update(); will wipe any changes you made
probably set teh BlockData back to the block
thank you!
Are bossbar titles editable and autoupdate?
changed to block.setBlockData(ageable);
What if I'm changing the progress ondeathevent
Do i still need a scheduler?
Ummm no comprende
Display total kills
Guys its possible to remove that original-... .jar file when maven compile without deleting the old .jar?
i dont like to delete the old .jar every time i need to compile
💀
you should really care about original-stuff or stuff-shaded
because those would be the incorrect jar to use
it generates me only two jars
how are you building
a correct jar, and that sh original-
maven package
do you have the shade plugin
dafuq
that doesnt add up
if you relocate/shade stuff it should also generate the-shaded jar
the shaded one only appears if i try to compile when the original- and the correct one jar already exists
i dont relocate
that might be why
use the jar with no additions
it will automatically delete those
so recompiling can just be invocing package
What you mean?
use the jar called project-version.jar not original-project-version.jar
and maven will automatically delete any present jars of that
when maven package is invoked
ok
💀
the mid one is the correct, but its really required to have that 3 jars on my project file?
lol damn english
only way i know that would do that is build elsewhere
Is there a way to create world in async?
no
no, if you wanna a faster world loader/creator, i recommend you to use the MultiverseCore's API
Ahha I got it 🙂
i have no idea what "this" means, are you able to explain what hes talking about?
its probably better if i explain what im doing. I want the bullet (which i identify by its pdc or metadata or wtv) to have a trail following it since i make the arrow invisible so you can tell if its a bullet or not
alr fixed it by just spawning particles while the arrow isnt dead or not on the ground
nope didnt work, just infinitely spawns particles, no idea
I keep hearing about how packet based plugins are best for high player counts, how does that work and is there any where I can read about that
?paste
what about
I dreamt about someone doing this
<dependency>
<groupId>org.example</groupId>
<artifactId>something</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>C:\Users\Someone\.m2\repository\org\example\something\1.0-SNAPSHOT\something-1.0-SNAPSHOT.jar</systemPath>```
i dont know
I do that every day


why do you hate yourself
well okay I know why you hate yourself. because you do stuff like this
and i stiiiiiiiiiiiiiillll havent fouuuuuuuuuund what im loooking foooooooooor
is it tobacco
omg after 4 days, my itunes backup rsync is complete
i forgot you were doing that
The only difference is that I usually do
<dependency>
<groupId>org.example</groupId>
<artifactId>something</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${user.home}\.m2\repository\org\example\something\1.0-SNAPSHOT\something-1.0-SNAPSHOT.jar</systemPath>
are you a bit stupid or sth?
lol
maybe
you should use more properties
but it works
slowly moving all of the music ever to my jellyfin :3
hippity hoppity your ip is now my property
you do realize it's a private subnet right?
it just depends on how u configure ur stuff
yeah
i say that to every ip i see
also wheres your i still dont care about cookies addon
yeah no mine were like 192.168.1.x
i dont care about cookies enough to install i dont care about cookies
i just blindly accept all
last night i had the strangest dream
lmfao
u said u had to get ur Laundry done
how often can I reheat chicken soup before it gets toxic?
I think I have heated it at least like 10 times by now but never ate it
why dont u pour it into a bowl and heat up the bowl
my mom follows like, cook it from frozen/chilled once and reheat it once
yeah
unfortunately I'm unable to do the same with mvn plugins
yeah
idk about reheating w like oven or stove tho
wtf
im pretty sure that would still be reheating it more than once
thats not how it works
r u continuously reheating the same bowl of soup in rapid succession?!
i bet you put hot food in the fridge
how fucking frozen was ur Soup
most of the time i forget to even pack leftovers immediately so they usually get room temp or colder
hey i'm using reflect to try to register a custom /tp command but minecraft keeps using the default tp command. anyway i can get it to use the reflect /tp command instead?
Why are you using reflection for commands
why do people still not use ACF
to dynamically load in all the plugin's commands instead of declaring them all individually. makes it easier to rapidly load commands.
Declare them individually
apparently it does not really make it easier
its similar to what plugins like CMI use
CMI is a pain
CMI is one of the worst plugins
my bug report from dec 2021 still hasnt been answered
wow, well if one of the top selling plugins is a terrible plugin i hope to be half as bad as CMI
thats not hard. just answer to bug reports within a year and you're already better
its nice to know that ya'll rather criticize than offer help in a help channel
show your code
If you want to fix your issue you need to reflect a bit more
there's also like 5 other command registration and processing classes that handle the dynamic loading
plus annotations
where is this weird CommandInfo annotation coming from?
also u dont need to include the imports
how do you register that command
naming conventions please
final CMD coreCommand = new CMD((CommandBase)entry.getValue().getConstructor((Class<?>[])new Class[0]).newInstance(new Object[0]), str, annotations);
pluginCommandList.add(annotations.command());
registerCommand(coreCommand);
private void registerCommand(CMD coreCommand) {
CommandInfo ci = coreCommand.getInfo();
// Check if there is a module required
if(ci.module().length() > 0) {
if (!modulesConfig.getBoolean(ci.module())) return;
}
//If there is no command then use the aliases as command
if(ci.command().length() == 0) {
for(String alias: ci.aliases()) {
CommandRegister cr = new CommandRegister(coreCommand, alias, ci.args(), ci.description());
cr.register();
}
} else {
CommandRegister cr = new CommandRegister(coreCommand, ci.command(), ci.args(), ci.description(), List.of(ci.aliases()));
cr.register();
}
}
?paste
sup fellas, this is more of a general java question, but im trying to remove an element from a hashmap and then iterate over the hashmap and change the indexes of the elements. but, i keep getting a ConcurrentModificationException. here's my code: https://paste.md-5.net/omuyekuyam.js
you cannot change a map while iterating over it, unless it's a ConcurrentHashMap
what is CommandRegister?
what in gods great name am i looking at
i have no clue
their run(...) method even takes in the plugins main instance
it's really weird
public void register() {
ReflectCommand cmd = new ReflectCommand(this.command);
if (this.description != null) cmd.setDescription(this.description);
if (this.alias != null) cmd.setAliases(this.alias);
if (this.usage != null) cmd.setUsage(this.usage);
if (this.permMessage != null) cmd.setPermissionMessage(this.permMessage);
getCommandMap().register("EpicCore", cmd);
cmd.setExecutor(this);
}
final CommandMap getCommandMap() {
if (cmap == null) {
try {
final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
f.setAccessible(true);
cmap = (CommandMap) f.get(Bukkit.getServer());
return getCommandMap();
} catch (Exception e) { e.printStackTrace(); }
} else if (cmap != null) { return cmap; }
return getCommandMap();
}```
private final class ReflectCommand extends Command {
private CommandRegister exe = null;
protected ReflectCommand(String command) { super(command); }
public void setExecutor(CommandRegister exe) { this.exe = exe; }
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (exe != null) { return exe.onCommand(sender, this, commandLabel, args); }
return false;
}
@Override public List<String> tabComplete(CommandSender sender, String alais, String[] args) {
if (exe != null) { return exe.onTabComplete(sender, this, alais, args); }
return null;
}
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
cmd.getCoreClass().run(EpicCore.getInstance(), sender, command, label, args);
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
CommandInfo ci = cmd.getInfo();
if(ci.tab().length > 0) {
for(String tab: ci.tab()) {
switch(tab) {
case "playername":
List<String> tabSort = new ArrayList<>();
for(Player player: Bukkit.getOnlinePlayers()) {
tabSort.add(player.getName());
}
return StringUtil.copyPartialMatches(args[0], tabSort, new ArrayList<>());
}
}
} else {
return cmd.getCoreClass().tab(sender, command, label, args);
}
return null;
}```
but realistically this all boils down to registering a command with reflect that already exists as a vanilla command not being accessible
you gotta replace the existing command map's "tp" command
also the reason you do this is so you can assign dynamic aliases for all commands
among a slew of other reasons
isnt that what commands.yml is for?
but it doesn't make it player changable
wdym
ofc server owners can
not with the plugin
can you have bukkit
if someone creates a script in my plugin and wants to run it as /barf or the ability to add dynamic aliases for a command that can be created on the fly
when was the last time that somebody said "oh I need to create a new alias for an existing command. thank god the plugin offers this itself, so I do not have to edit commands.yml" lol
custom aliases = use commands.yml
its less coding on my end. so i can just provide a list of aliases that can be a command
less coding? you literally just sent two screens of command registration code
where you usually only need one line
i only have to edit / create 1 file to make a command, create the functions, or aliases. it also allows me to use wrappers so people can disable commands individually or based on the module they're in
your method is just a dirty workaround to do things that bukkit can do with builtin methods
i'd rather not muddy up my main class with 100+ manual command additions
and since that doesn't use a framework it makes it harder to make changes en mass
yeah instead you write 200 lines of code that hack into the command map with reflection and it doesnt even work
it works just not with default commands, but like you said, i can just remove the default command from the command map
yeah that's what you gotta do
the default command map looks like this:
"minecraft:tp" -> something
"tp" -> something
etc
it includes both, the namespaced and non-namespaced commands
in the list folder it automatically adds all those commands. the 5 files on the bottom are the loader / manager. it makes the initial load a little heavy but makes everything else happen rapidly
you should really think about using proper class names
and what would be a proper class name in your eyes
That's just like your opinion man
100%
stop urinating on my carpet, md5
I use normal naming conventions through everything that's not dynamically loaded
as you can see with EpicCoreCommand and CommandBase, CommandInfo, etc..
i bet you name commands like Commandtp
like essx
if its dynamically loaded, the command name is the class because i never have to reference it
i wonder whether "TheDude" nickname is already taken on spigotmc
without a doubt
how old are these references
like anyone has seen airplane
by bf didnt even knew that movie existed
granted, he's only 20
and he doesnt like BTTF so yeah he's a weirdo
ExtremelyLongAndOverlyComplicatedTeleportationCommandExecutorClassForSpigotMinecraftServerPluginImplementation
oh so like
ExtremelyLongAndOverlyComplicatedTeleportationCommandExecutorClassForSpigotMinecraftServerPluginImplementation extremelyLongAndOverlyComplicatedTeleportationCommandExecutorClassForSpigotMinecraftServerPluginImplementation = new ExtremelyLongAndOverlyComplicatedTeleportationCommandExecutorClassForSpigotMinecraftServerPluginImplementation();
hmmm
public void unregister(String cmd){
try {
CommandMap commandMap = getCommandMap();
final Field f = commandMap.getClass().getDeclaredField("knownCommands");
f.setAccessible(true);
final Map<String, Command> commands = (Map<String, Command>) f.get(commandMap);
commands.remove(cmd);
}catch (Exception e){
e.printStackTrace();
}
}```
no such field as knownCommands
try using SimpleCommandMap instead of just CommandMap?
i guess this forum post was hella old
or try final Field f = SimpleCommandMap.class.getDeclaredField("knownCommands"); and then continue on as u have it
i did
why didnt you tell...
this was me telling
no such field kinda implies an exception thrown
oh ok
since its called NoSuchFieldException p sure lol
i havent seen that
Balls
why do english speaking people always use genitals to describe things that suck
you built a time machine - into a delorean?!
Say it together
einstein is so cute
the dog
