#help-development

1 messages · Page 1761 of 1

twilit wharf
#

wait, nevermind

#

it is the first thing being set on onEnable

tawny horizon
#

hm,m

#

does Started scheduled task ever print?

rough jay
#

can this

for (int i = 0; i < players.size(); i++) {
    if (players.get(i).equals(player.getName())) {
        players.remove(i);
    }
}

be replaced with this?

players.removeIf(s -> player.getName().equals(s));
tawny horizon
#

what is players?

tawny horizon
#

a list i would assume?

tawny horizon
rough jay
acoustic pendant
#

static double Mana = 100;
static double MaxMana = 100;

#

to separate things like this per players

#

how am i supposed to do it?

#

with a hashmap or something like that?

rough jay
#

yes

tawny horizon
acoustic pendant
#

hmm

#

i want that players

rough jay
#

Also, will the method always return true/false, or does the return value changes at it should?

private boolean removePlayerFromGroup(YamlConfiguration yaml, OfflinePlayer player, String group) {
    List<String> players = yaml.getStringList(group);
    List<String> newPlayers = players;
    newPlayers.removeIf(s -> player.getName().equals(s));
    yaml.set(group, newPlayers);

    try {
        yaml.save("plugins/MaxiCity/teams.yml");
    } catch (IOException e) {
        e.printStackTrace();
    }

    return players.equals(newPlayers);
}
acoustic pendant
#

they start all with 100

#

but can change that

tawny horizon
acoustic pendant
#

each player

rough jay
#

yeah ik I'm trying something else now

tawny horizon
#

you need to at the very least replace

newPlayers.removeIf(s -> player.getName().equals(s));

with

newPlayers.removeIf(s -> player.getName().equals(s.getName()));
rough jay
#
boolean flag = players.removeIf(s -> player.getName().equals(s));

If a player's name is removed from players, will flag be true or false?

tawny horizon
acoustic pendant
#

i want to be different for everyone

#
public class perPlayerStats {


    Map<UUID, Double> mana = new HashMap<>();

    public void separateMana(Player player){
        mana.put(player.getUniqueId(), ManaStatMain.MaxMana);
        
    }



}```
#

trying something like this

tardy delta
#

private brrrr

tawny horizon
rough jay
acoustic pendant
tardy delta
#

ah its a string

tawny horizon
rough jay
#

Here's how it's done

private boolean removePlayerFromGroup(YamlConfiguration yaml, OfflinePlayer player, String group) {
    List<String> players = yaml.getStringList(group);
    boolean flag = players.removeIf(s -> player.getName().equals(s));
    yaml.set(group, players);

    try {
        yaml.save("plugins/MaxiCity/teams.yml");
    } catch (IOException e) {
        e.printStackTrace();
    }

    return flag;
}
rough jay
tawny horizon
#

or YML

tawny horizon
acoustic pendant
#

ty!

tawny horizon
#

mhm

rough jay
quaint mantle
#

These perms are automatically set to default: op? (names are just for example)

opal juniper
#

no

quaint mantle
#

ok

opal juniper
#

you must declare them as well

quaint mantle
#

ok, thanks

twilit wharf
tawny horizon
# rough jay <@!903590286209482843> am I all good? https://pastebin.com/kq1nvvgg

I would recommend storing groups in data files and loading them on the plugin enable and storing them in a hashmap

Here is how I would recommend doing it.

public class Group {

    @Getter
    private final static HashSet<Group> allGroups = new HashSet()<>;

    @Getter
    private final HashSet<UUID> playersList = new HashSet()<>;

    @Getter
    private final String groupName;

    public Group(String groupName) {
        this.groupName = groupName;
        allGroups.add(this);
    }

    public void addPlayerToGroup(UUID playerUUID) {
        playersList.add(playerUUID);
    }

    public void removePlayerToGroup(UUID playerUUID) {
        playersList.remove(playerUUID);
    }
}
#

something like that

#

You could also make a HashMap with every UUID and their corresponding group for quick checking on that

#

that way you dont have to load a YML file every time you need to add / remove someone from a group

#

just save the file every 5min or so

#

and onDisable()

rough jay
tawny horizon
tawny horizon
#

and permissions

rough jay
#

I haven't really tested perms but the playerDataMap works fine and is saved

twilit wharf
tawny horizon
#

for whatever reason

rough jay
tawny horizon
#

the file would be scanned once

rough jay
#

you can't only scan the file once

#

what if it gets changed?

twilit wharf
tawny horizon
#

The only way the file should be changed is through your code

tawny horizon
rough jay
#

well no because if an admin has an access to the file then he can change it. I know people like us would know to only change the file via code (the command I made earlier) but for some people it's not that clear, and I need to make the code "break-proof"

twilit wharf
tawny horizon
tawny horizon
#

hmm

lean gull
#

does anyone have a good tutorial for a tab plugin with a config file? i want to make a plugin that has its own yml file, and in that file there's a header section and a footer section, and you can change like 5 lines of each section, and also have like the player ping, server tps, etc etc

twilit wharf
#

look him up on YouTube

twilit wharf
#

oh, then idk

tawny horizon
#

@rough jay should players be allowed to be in more than one group at once?

twilit wharf
# tawny horizon Ok, so its not null.

maybe there is a better way to do it than a Bukkit schedule delay? all i want is to wait 5 min and try again, over and over, without stopping everything else

tawny horizon
#

?paste

undone axleBOT
tawny horizon
# rough jay they can yeah

If you want I wrote this really quick, you could check it for bugs but i doubt there are any. https://paste.md-5.net/lujumuxari.java

It would handle all of the logic of taking care of groups and checking who is in what group, saving data, and so on.

Note: The "saveAllData()" method needs you yo actually write the config.save() method at the bottom of it (accidently left it out). Also feel free to make the groups non-case sensitive (i just made it case sensitive by defualt)

#

Also, it would mean they dont have to add permissions for groups

quaint mantle
#

add entity to the team and set the color's team to glow color you want]

tawny horizon
ivory sleet
#

they probably said ew because that class is not unit testable and quite rigorously written Ig but its probably fine concerning this isnt some sort of enterprise

rough jay
tardy delta
#

is there a way to keep fly when changing gamemode to survival?

tacit drift
#

setAllowFlying true

#

or something like that

#

and setFlying true

glossy venture
#

i think you can just set someone flying

#

Player#setFlying(true)

#

i believe

glossy venture
#

lemme check docs

tacit drift
#

that it's like creative fly

glossy venture
#
Player.setAllowFlight(true);
Player.setFlying(true);
#

like that

tawny horizon
#

in a more efficient way

glossy venture
#
new HashSet()<>
``` wait is this possible?
#

no

rough jay
#

I don't understand like 90% of the code @tawny horizon

quaint mantle
rough jay
#

like why does addPlayerToGroup only take a Player as parameter? the method is not named correctly then

tardy delta
# glossy venture i think you can just set someone flying

well yea doest work

@EventHandler
    public void onGamemodeChange(PlayerGameModeChangeEvent event) {
        Player player = event.getPlayer();
        if (CommandFly.getFlyingPlayers().contains(player.getUniqueId())
            && event.getNewGameMode() == GameMode.SURVIVAL)
            player.setAllowFlight(true);
    }
glossy venture
tawny horizon
shrewd hemlock
#

is there a way to detect when a player touch the ground?

glossy venture
#

it should work

#

so then the statement is not reached

rough jay
glossy venture
#

also you might have to do player.setFlying(true) after it

#

idk

tawny horizon
glossy venture
#

so to the group

#

it adds the player to the group

#
public void
``` no static
tawny horizon
ivory sleet
#

I mean srp just states classes should only change for one major reason

quaint mantle
#

who is toptal

rough jay
glossy venture
#

idk

#

i didnt write it

#

as dianaa

tawny horizon
#

Here is the thing, using 2 classes for handling groups vs 1 single class makes it more confusing for someone who is new to use, the purpose of me writing that was to make it as easy as possible to use

tawny horizon
#

when you create the instance

ivory sleet
#

how does it make it more confusing thonk

rough jay
#

so if I have 6 groups I need 6 instances?

glossy venture
#

when you do new Group("name")

glossy venture
tawny horizon
tawny horizon
ivory sleet
#

extra steps doesnt mean something is inherently more confusing

tawny horizon
ivory sleet
#

No it’s less to keep track of

#

If you have isolated responsibilities in different classes then you have reduced the amount of complexity in each class as opposed to just using one single class

tawny horizon
#

calling the load method in onEnable

#

and save method every 5min or so and once in onDisable

rough jay
#

so it means I replace my enum Group with your class?

tawny horizon
rough jay
#

I still don't get how is your way better... my enum is good, I don't have to register anything because it's static

ivory sleet
#

Which is bad

lean gull
tawny horizon
#

thats why I wrote that, it does it once when the server loads

#

and thats about it other than saving

rough jay
# ivory sleet Which is bad

well no because with their code, I have more HashMaps which means more data to save.
I already have a HashMap for each player with datas of other things in my plugin and when a player has a Group, his group is stored in the HashMap

#

aaaah

rough jay
ivory sleet
#

More HashMaps doesn’t even imply it’s more data to save necessarily

tawny horizon
#

other than one line on the save method where you have to just type config.save(file)

#

at the bottom of the method

#

only one of the maps has anything saved from it at all

rough jay
#

well no because if I use your code, I would still load the file each time a player connects and use the method to load the data or something like that

tawny horizon
#

the other maps are used to make accessing data in the class easier

tawny horizon
#

and then save it onDisable

#

the file would not need to be touched

rough jay
#

well if someone changes the file

quaint mantle
#

Hashmap contains another hashmap i mean

tawny horizon
#

those are never meant to be edited any way other than through code

rough jay
#

😂

rough jay
quaint mantle
tawny horizon
rough jay
#

It's a dream inside of a dream

#

so HashMap inside of HashMap would be HashMapCeption (it's a joke)

quaint mantle
#

Joje

#

Jole

rough jay
#

joke 😂

left swift
#

how can i make an entityarmorstand that has something similar to noclip? I would like to give it velocity, but when it's in a block it gets stuck

quaint mantle
#

Or just see some hacked client source then…

#

Hacked clients are mods

#

and im sure it works completely differently since its on client-side

foggy estuary
#

does anyone know how to add players to a scoreboard

quaint mantle
#

also i've never saw a cheat with noclip for mc lol

opal juniper
#

its the other way around i think

#

you add a scoreboard to a player

left swift
quaint mantle
#

Probably the best it's going to get

tardy delta
#

whats the best way of saving namespacedkeys?

ivory sleet
#

Like persistently?

tardy delta
#

i was thinking of storing them in a class

ivory sleet
#

Oh I just have a soft cache for it sort of

left swift
chrome beacon
#

You will have to mess with NMS

#

Create your own entity and override the collision detection

quaint mantle
#

toString and fromString?

tardy delta
#

@paper viper said me to

#

.

paper viper
#

Singleton

eternal oxide
#

NamespacedKeys are just strings

foggy estuary
# opal juniper you add a scoreboard to a player
    //The scoreboard display
    public void OnJoin(PlayerJoinEvent event) {
        createBoard(event.getPlayer());
    }
    
    public void createBoard(Player player) {
        
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Objective obj = board.registerNewObjective("test", "dummy",(ChatColor.GOLD + "Bank Heist"));
        
        obj.setDisplaySlot(DisplaySlot.SIDEBAR);
        Score score = obj.getScore(ChatColor.RED+ "Most Gold Collected:");
        score.setScore(3);
        obj.getScore(ChatColor.RED + "Most Gold");
        score.setScore(2);
        obj.getScore(ChatColor.RED + "Time Left");
        score.setScore(1);
        player.setScoreboard(board); ``` Can you explain how i would do it i cant find anything to do it.
quaint mantle
#

no magic

ivory sleet
# tardy delta i was thinking of storing them in a class

Used to have a class called NamespacedKeyProvider which encapsulated a Map<String,SoftReference<NamespacedKey>> then whenever I needed a key I checked if that key existed within the map, if not then I created a new one and stored it in the map.

quaint mantle
#

but why

#

i dont think creating a namespacedkey that expensive

ivory sleet
#

Because I had around 2000 keys

#

so if it was urgently needed, it would go ahead and gc unused ones given that they weren’t used anywhere else (softly reachable)

left swift
#

what is te best way to add to armorstand natural mob movement (like a pig etc.)

quaint mantle
#

i've already answered 😦

left swift
#

but actually I have a question for you 😄

#

when i spawn that nms pig, and nms armorstand then it doesn't have any movement, how can i fix that?

quaint mantle
#

show the code

left swift
#
        EntityPig entityPig = new EntityPig(EntityTypes.an, ((CraftWorld) location.getWorld()).getHandle());
        this.ID = entityPig.getId();
        entityPig.setPosition(location.getX(), location.getY(), location.getZ());

        PacketPlayOutSpawnEntityLiving spawnEntityPig = new PacketPlayOutSpawnEntityLiving(entityPig);
        PacketPlayOutEntityDestroy destroyEntityPig = new PacketPlayOutEntityDestroy(ID);

        PacketPlayOutSpawnEntity spawnEntity = new PacketPlayOutSpawnEntity(ID, entityPig.getUniqueID(), location.getX(), location.getY(), location.getZ(), entityPig.getXRot(), entityPig.getYRot(), EntityTypes.c, 0, entityPig.getMot());


        sendPackets(spawnEntityPig, destroyEntityPig, spawnEntity);```
quaint mantle
left swift
#

I do not understand 😕

tardy delta
#

world.spawnEntity(EntityType.Pig) or something

paper viper
glossy venture
#

there should be a method for spawning entities in an nms world

left swift
hybrid spoke
#

depends on what you are trying to do

quaint mantle
#

as i can understand, he wants to make armorstand act like a pig

left swift
#

armorstand with natural mob movement

quaint mantle
#

i thought the easiest way of doing it was replacing pig with armor stand via packets, like LibsDisguises does

glossy venture
#

if you dont want the pig shown dont send packets

quaint mantle
#
  1. Spawn a pig with api
  2. Destroy it using packets
  3. Spawn an armorstand with same entity id as pig using packets
glossy venture
#

do you mean destroy it on clients using packets?

quaint mantle
#

yes

glossy venture
#

but then the entity id is still taken

#

on the server

quaint mantle
#

we dont need a new entity on the server

glossy venture
#

oh you mean armor stand on client

#

using packets

left swift
#

Works! thx manya!

#

is it possible to edit this armorstand? hand movement, adding items etc?

quaint mantle
#

that easy? glad to help!

quaint mantle
left swift
#

ok, and is it possible to change the Y pos of the armorstand?
I mean armorstand go into the ground

azure nova
#

hello! I want to update a scoreboard every 5 seconds, I have read about Runnable and stuff like that, but it's still really confusing for me...All i want is just mere hints, of how do I do it 🥺 , like PROBABLY for no lags, I think updating the scoreboard asnyc would be a good idea? and cause if I update a scoreboard every 5 seconds on main thread, wont that cause lag? cause it wont be just updating a scoreboard but also displaying it on the player screen, right....right?

eternal oxide
#

?scheduling Don;t do it async

undone axleBOT
graceful turret
#

how to get material from numeric ID i mean for example stone = 1, air = 0 etc.

eternal oxide
#

We don't use magic numbers any longer

tardy delta
#

btw my actionbar for every player who joins the server is async, is that a good way or not?

eternal oxide
#

Yes its fine. But for someone who is unsure of how to use a Runnable its not.

quaint mantle
#

yes sending messages async is fine

#

(unless you start an async thread everytime you send it)

pearl sparrow
#

Hello everyone, is there a way of programmatically turning on and off a core shader that is within a resource pack? I am referring to core shaders that were added recently.

tardy delta
#

i have it like in the playerjoinevent new ActionBar.runTaskAsync(blablalbla)

tardy delta
#

ki

quaint mantle
#

idk if player.getHealth is a problem

tardy delta
#

getHealthScale does also exist but i dunno what it does

#

it works so i dont care

#

uhh

quaint mantle
#

getInstance 😒

tardy delta
#

that runs it immediatly when creating it

#

nvm

#

it looks kinda the same

#

but why not extending runnable?

quaint mantle
#

bruh i use constructors

quaint mantle
# tardy delta

this staff may lead to the memory leak, you shouldnt use direct Player references

#

i guess just cancel a task when player leaves

tardy delta
#

wdym? cant i use a player object?

eternal oxide
#

a Player object may go stale

opal juniper
#

what he said

eternal oxide
#

a UUID will not

tardy delta
#

but i need to send an actionbar so i need an player object

eternal oxide
#

get teh player object when you need it

quaint mantle
#

but it seems unecessary to do uuid lookup everytime

eternal oxide
#

I guess it depends on how often you need it and how reliably you are dropping the player reference when teh player leaves

tardy delta
#

i dont completely understand

quaint mantle
#

ElgarL, do you write "teh" on purpose?

eternal oxide
#

no

ivory sleet
# tardy delta wdym? cant i use a player object?

Ofc you can, but the Player interface and its implementation wasn’t created to be a key for maps nor stored, though it does support HashMaps by implementing hashCode and equals. Ideally it’s just a context object really.

elfin talon
#

Hey if I want to work with Craftserver etc.. Do I have to add the complete Spigot version as an external libary or is there an alternative?

#

I want to spawn npcs

#

?

ivory sleet
#

yeah

#

you'd have to add the actual server jar itself to your compile classpath

ivory sleet
tardy delta
#

athough i dont see a map here

ivory sleet
#

I'd say UUID, it's resistant against invalid Player instances or whatever else you might encounter

tardy delta
#

i need to call player.spigot() every time when updating the actionbar so why would i choose for an uuid where i need to call Bukkit.getPlayer(uuid) every time?

mighty burrow
#

could someone help me with the vault api? I've got essentials installed as well as vault. it logs [Vault] [Economy] Essentials Economy hooked.. however, when i try to get the service using Bukkit.getServer().getServicesManager().getRegistration(Economy.class), it just returns null

ivory sleet
#

Idk the very case here, but yes the drawback of using UUID is that we have to rely on looking up Player by UUID, which in some cases might be redundant if you can assert that the object which strongly references the player is only used during the player's valid session. If you are not sure, and you don't want to use Server::getPlayer then maybe go with a WeakReference<Player> which won't stop the player object to get gc'd.

mighty burrow
#
public static boolean doServiceChecks() {
        
        if (Bukkit.getPluginManager().getPlugin("Vault") == null)
            return false;
            
        if (!Bukkit.getPluginManager().getPlugin("Vault").isEnabled())
            return false;
            
        if (!Main.getPlugin().getClanConfiguration().isVaultEnabled())
            return false;
 
            
        if (service == null)
            service = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
 
        System.out.println(service == null ? "service is null" : service.toString());

        if (service == null)
            return false;
             

        return true;
    }
#

it prints service is null everytime

ivory sleet
#

when do you call that method?

mighty burrow
#

so, i have another package which is discord bot code, i call this static method from a command executor for the bot

#
 @Override
    public void execute(Message msg, ArrayList<String> args) {
        if (args.size() <= 0) {
            msg.reply("Mention a player!").queue();
            return;
        }
        
        String plrName = args.get(0);
        @SuppressWarnings("deprecation")
        OfflinePlayer plr = Bukkit.getOfflinePlayer(plrName);

        if (VaultHook.doServiceChecks()) {
            System.out.println("in here"); 
            double balance = VaultHook.getBalance(plr);

            msg.reply(String.valueOf(balance)).queue();
        }
       
    }
#

heres that if required

tardy delta
#

i dont even knows what happens when the player leaves the server

#

it keeps running guess

#

no errors

quaint mantle
#

How do you think, is making Clans immutable a good idea? Clan has methods to set display name, add and remove members and homes. the problem is that with immutability i'd have to re-add a clan to the clan manager everytime when i change the clan

ivory sleet
ivory sleet
ivory sleet
mighty burrow
# ivory sleet anyways point is, for that former code to work, vault must be loaded before you ...

i do have both the vault and EssentialsX-2.19.0 plugins. vault even logs this: [Vault] [Economy] Essentials Economy hooked . about vault not being loaded, it passes through the initial checks right?

if (Bukkit.getPluginManager().getPlugin("Vault") == null)
            return false;
            
        if (!Bukkit.getPluginManager().getPlugin("Vault").isEnabled())
            return false;
            
        if (!Main.getPlugin().getClanConfiguration().isVaultEnabled())
            return false;

or does this not ensure that it is loaded? if so, how can i do that

ivory sleet
#

Though Idk if you deal with some sort of multithreaded system here, in that case maybe having it immutable could make it automatically thread safe (apart from the manager)

quaint mantle
#

no, not really. Just thinking about immutability design overall

#

adventure looks sexy

ivory sleet
#

Yeah lol, though some of adventure is just "virtually immutable"

ivory sleet
#

(with for instance printing to sysout)

mighty burrow
#

it logs service is null

tardy delta
ivory sleet
#

thats once

#

Rohith you probably want to print for every branch

#

(every if statement)

mighty burrow
#

everytime i run the -bal command from discord, it prints that

ivory sleet
#

to see where exactly it stops

mighty burrow
#
ublic static boolean doServiceChecks() {
        
        if (Bukkit.getPluginManager().getPlugin("Vault") == null)
            return false;
            
        if (!Bukkit.getPluginManager().getPlugin("Vault").isEnabled())
            return false;
            
        if (!Main.getPlugin().getClanConfiguration().isVaultEnabled())
            return false;
 
            
        if (service == null)
            service = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
 
        System.out.println(service == null ? "service is null" : service.toString());

        if (service == null)
            return false;
             

        return true;
    }
young knoll
#

Did you depend on vault in the plugin.yml

mighty burrow
#

if it prints service is null, that means it doesnt stop at the if statements right?

tardy delta
#

something like this?

mighty burrow
#

plugin.yml

ivory sleet
#

isnt it named EssentialsX?

mighty burrow
#

oh

ivory sleet
#

(idk acc)

mighty burrow
#

i'll try that

ivory sleet
#

sure do lol

mighty burrow
#

but see

#

this method is being called long after the server has loaded

#

(coz i have to get on discord and type the command)

#

its still null :/

tardy delta
#

EssentialsX should work i guess

mighty burrow
#

yh im tryin that

tardy delta
#

me struggling with static keyword..

young knoll
#

static public static void static

mighty burrow
#
[23:31:11] [Server thread/INFO]: [Vault] [Economy] Essentials Economy hooked.
[23:31:11] [Server thread/INFO]: [Essentials] Using superperms-based permissions.
[23:31:11] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[23:31:13] [Server thread/INFO]: Done (38.593s)! For help, type "help"
[23:31:13] [Server thread/INFO]: [Essentials] Essentials found a compatible payment resolution method: Vault Compatibility Layer (v1.7.3-b131)!  
[23:31:13] [Craft Scheduler Thread - 0/INFO]: [Vault] Checking for Updates ...
[23:31:13] [Craft Scheduler Thread - 1/INFO]: [Essentials] º6Fetching version information...
[23:31:14] [Craft Scheduler Thread - 0/INFO]: [Vault] No new version available
#

thats the log just for clarification

#

nope still prints 'service is null'

tardy delta
#

illegal combination of modifiers static and static :kekw:

mighty burrow
#

aagh ive been on this for a day now

#

i feel like its something stupid im doing

tardy delta
#

need a static plugin instance only to get its name smh

young knoll
#

Just store the name instead?

tardy delta
#

i only need it once and making a private field for that goes brr

ivory sleet
#

anyways this is what I used to do:

interface EconomyProvider {
  Economy getEconomy();
}
class JavaPluginImpl extends JavaPlugin implements EconomyProvider {
  private Economy economy;

  @Override public void onEnable() {
    this.getServer().getBukkitScheduler().runTask(this,() -> {
      this.economy = this.getServer().getServicesManager().load(Economy.class);
    });  
  }

  @Override public Economy getEconomy() {
    return this.economy;  
  }
}```
Then whenever you need economy thing you pass an instance of EconomyProvider (in my case it was the plugin instance)
mighty burrow
#

hm lemme try that

left swift
#

how can i edit entity nms position via packets? (after spawn)

jade perch
#

Protocolib

quaint mantle
#
public class Swing implements Listener{
    private Main plugin;
    private int task1;
    
    public Swing(Main plugin)
    {
        this.plugin = plugin;
        Bukkit.getPluginManager().registerEvents(this, plugin);
    }
 
    @EventHandler
    public void SwingEvent(PlayerInteractEvent e)
    {
 
        if(e.getAction() == Action.LEFT_CLICK_AIR) {
   
            Player p = e.getPlayer();
            Block b = p.getTargetBlock(null, 120);
            String name = p.getName();
           
            if(b != null && !b.getType().isAir()) {
            
          World w = p.getWorld();
         Location l = p.getLocation();
         
          LivingEntity bat = (LivingEntity) w.spawnEntity(l, EntityType.BAT);
             bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY,100000,100000));
            bat.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,100000,100000));
      
                Vector v = l.getDirection();
                Arrow arr = w.spawnArrow(l.add(v.clone().normalize().multiply(2) ),v, 10f, 0);
                bat.setLeashHolder(arr);
       
             BukkitScheduler sched = p.getServer().getScheduler();
               task1 = sched.scheduleSyncRepeatingTask(plugin, new Runnable() {
           
                    @Override
                    public void run() {
               
                        if(arr.isInBlock()) {
    
                            p.teleport(p.getLocation().add(0,0.5,0));
                            p.setVelocity(v.clone().multiply(5));
                            p.setFallDistance(-100f);
                            bat.remove();
                           arr.remove();
                            sched.cancelTask(task1);
                        }
                        if(arr.getTicksLived() >= 40) {
                        bat.remove();
                         sched.cancelTask(task1);
                        }       
                    } 
                }, 0L, 10L); }} }```
#

?paste

undone axleBOT
quaint mantle
#

Why isn't this working? You are supposed to "swing" like Spiderman but as soon as you use it with two players it barks and starts to teleporting you all over the place.

pastel mauve
#
        ChunkData data = createChunkData(world);

        for(int x = 0; x<16; x++) {
            for(int z = 0; z<16; z++) {
                data.setBlock(x, 0, z, Material.BEDROCK);
                data.setBlock(x, 1, z, Material.GOLD_BLOCK);
                data.setBlock(x, 2, z, Material.REDSTONE_BLOCK);
                data.setBlock(x, 3, z, Material.COAL_BLOCK);
                data.setBlock(x, 4, z, Material.GLASS);
            }
        }
        
        return data;
    }```
How can I create a world using this Chunkdata?
patent horizon
#

is there an event specifically for clicking entities?

#

or is there a way i can grab the clicked entity in an interact event?

hasty prawn
#

PlayerInteractEntityEvent

patent horizon
#

ah tyvm

opal juniper
#

id use PlayerInteractAtEntityEvent but its up to u

quaint mantle
#
    private Main plugin;
    private int task1;
    
    public Swing(Main plugin)
    {
        this.plugin = plugin;
        Bukkit.getPluginManager().registerEvents(this, plugin);
    }
 
    @EventHandler
    public void SwingEvent(PlayerInteractEvent e)
    {
 
        if(e.getAction() == Action.LEFT_CLICK_AIR) {
   
            Player p = e.getPlayer();
            Block b = p.getTargetBlock(null, 120);
            String name = p.getName();
           
            if(b != null && !b.getType().isAir()) {
            
          World w = p.getWorld();
         Location l = p.getLocation();
         
          LivingEntity bat = (LivingEntity) w.spawnEntity(l, EntityType.BAT);
             bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY,100000,100000));
            bat.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,100000,100000));
      
                Vector v = l.getDirection();
                Arrow arr = w.spawnArrow(l.add(v.clone().normalize().multiply(2) ),v, 10f, 0);
                bat.setLeashHolder(arr);
       
             BukkitScheduler sched = p.getServer().getScheduler();
               task1 = sched.scheduleSyncRepeatingTask(plugin, new Runnable() {
           
                    @Override
                    public void run() {
               
                        if(arr.isInBlock()) {
    
                            p.teleport(p.getLocation().add(0,0.5,0));
                            p.setVelocity(v.clone().multiply(5));
                            p.setFallDistance(-100f);
                            bat.remove();
                           arr.remove();
                            sched.cancelTask(task1);
                        }
                        if(arr.getTicksLived() >= 40) {
                        bat.remove();
                         sched.cancelTask(task1);
                        }       
                    } 
                }, 0L, 10L); }} }```
#

Why isn't this working? You are supposed to "swing" like Spiderman but as soon as you use it with two players it barks and starts to teleporting you all over the place.

eternal oxide
#

you'd need a task per player

opal juniper
#

what is this indent lol

#

all over the place

quaint mantle
eternal oxide
#

a HashMap

quaint mantle
opal juniper
#

no

#

something like

#

Map<UUID, Integer>

#

instead of task1

#

So like

#

.put(player.getUniqueId(), sched.scheduleSyncRepeatingTask(...));

quaint mantle
#

so instad of task1 = sched.scheduleSyncRepeatingTask(plugin, new Runnable() i do what?

eternal oxide
#

You don;t seem to actually be using teh task ID other than to cancel

#

use a BukkitRunnable, pass the player to it so it only acts on that specific player, then you can call this.cancel() when finished

#

you will need to track what players have an active runnable, so you don;t start a second (if thats possible)

fresh pollen
#

Someone pass me a code for peaceful animals to attack players? :(

opal juniper
#

called google

patent horizon
#

since you spawn your bat as a living entity already, you can just do bat.setInvisible(true);

hybrid spoke
opal juniper
hybrid spoke
patent horizon
jade perch
#

Has 16k downloads I'm sure it's fine

hybrid spoke
#

#######################################################
Discord: https://discord.gg/U5dwKr3
#######################################################
Tutorial Pack Download: https://drive.google.com/open?id=1n6GE6qWwOQEH8jSnfUPpC719QWbbxfAK
#######################################################
Inspired by my tutorials? Consider donating to help ...

▶ Play video
opal juniper
#

downloads != safe

jade perch
#

Just a weird amount of effort to put in to make a malicious jar

opal juniper
#

yeah idk

jade perch
#

He probably using it for reflections or some sheet

glossy venture
#

what does javassist do again?

#

isnt it like runtime patching or something?

opal juniper
#

reflection and bytecode modifications iirc

glossy venture
#

at runtime right?

#

thats pretty cool

#

and what was objectweb asm

#

or is

wet stream
#

I have an error: java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.isurvialx.tutorial1.Tutorial1.getCommand(String)" is null package com.isurvialx.works;

import org.bukkit.plugin.java.JavaPlugin;

public final class Works extends JavaPlugin {

@Override
public void onEnable() {
    // Plugin startup logic
    super.onEnable();
    getCommand("pomoc").setExecutor(new PomocCommand());
}

} package com.isurvialx.works;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class PomocCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player)sender;
p.sendMessage("§lIt works");
return false;
}
}
main: com.isurvialx.works.works
version: 1.0
author: Isurvialx
name: Tutorial
description: Interesujaca komenda

commands:
pomoc:
usage: /pomoc
description: sends something
aliases: /xhelp

hybrid spoke
#

ok cool

#

ah

tardy delta
#

set the command in the plugin.yml?

chrome beacon
#

^

opal juniper
#

^

tardy delta
#

btw if you register a command with the commandMap field and that strange stuff, do you still need to have them in your plugin.yml?

jade perch
#

Noe

tardy delta
#

aah

wet stream
#

I see the plugin but the command doesnt work

pastel mauve
#

Does somebody know how to set up a new world with custom chunk data?

runic mesa
#

How would I add something like a dessert table

#

Like editing world gen

digital rain
#

just uhh what to use if i want to do a delayed task, but want to return a boolean from it

#

since schedulesyncdelayedtask doesnt cover that

#

basically searching for a soultion to this

lavish hemlock
#

it does not contain runtime patching

#

you'd have to implement that yourself via custom classloader

#

(although, it's not particularly hard)

quaint mantle
#

thats absolutrly redundant in most cases smh

patent horizon
#

is there a resource website or smth for protocol lib examples?

tacit drift
#

the github

lavish hemlock
#

wellll, ASM should be faster than Javassist since it's incredibly optimized, and Javassist doesn't use ASM but instead its own higher-level API.

tacit drift
quaint mantle
tacit drift
#

yeah

#

spreads to everything that is a jar on your server

fresh pollen
patent horizon
#

uh

#

ive never done it

#

i've just used mythic mobs

quasi patrol
#

Getting this error:

#
        name.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.translateAlternateColorCodes('&', "&aName: &a" + player.getName())), new Text(PlaceholderAPI.setPlaceholders(player, "&6Balance: %vault_eco_balance_commas%"))));
        event.setFormat(ChatColor.translateAlternateColorCodes('&', name + " &8\u00BB&f ") + ChatColor.RESET + event.getMessage());```
quaint mantle
#
  1. Dont use legacy color codes in components
  2. AsyncPlayerChatEvent doesnt support components
#

(but on paper it does 🙂)

upper tendon
#

Is there a way I could convert a String (given through a command argument) into a material? (like if someone put STONE_SLAB, I could make an ItemStack with material type stone slab)

upper tendon
#

Oh sweet, thanks

young knoll
#

If you want to use components on the chat event with spigot you have to manually send a new message to everyone

patent horizon
granite beacon
#

is there a way to dynamically change a tasktimer (aside from canceling and creating a new one.)

quaint mantle
#

wdym by dynamically change

granite beacon
#

like changing this bit

quaint mantle
#

no not really

granite beacon
#

so best way would just be to cancel the current one and schedule a new one with the new timer?

quaint mantle
#

you may run it every tick and count them by yourself

granite beacon
#

that wouldn't impact performance?

quaint mantle
#

no

granite beacon
#

dope

#

just to understand it a bit better

#

why would it not impact performance? is it like subscribing to an event that runs x amount of ticks?

ivory sleet
#

It does impact performance

#

Because it has to invoke your runnable every tick

#

But it’s negligible to the extent that it doesn’t impact really

quaint mantle
#

but thats actually nothing

granite beacon
quaint mantle
#

depends

#

how oftenly does the period change

granite beacon
#

it's based on how many players are using it

#

so

ivory sleet
#

well

granite beacon
#

not very very often

#

but kinda often

ivory sleet
#

You’d basically skip the logical code execution when it’s the wrong tick right?

quaint mantle
#

y-yeah

ivory sleet
#

Yeah then it really doesn’t matter

granite beacon
#

dope

#

Thanks 🙂

ivory sleet
#

I mean you could re schedule a new task everytime but it comes with some other problems

quaint mantle
#

thats annoying at the first place isnt it

granite beacon
#

true

ivory sleet
#

For instance you have to keep track of each individual BukkitTask instance which gets created every time. Then it also increments task id tracker unnecessarily.

#

For the former ofc you don’t have to keep track of them, but you might need it in the future if you want proper cancellation or something

granite beacon
#

I don't think keeping track of them would be an issue but I do see what you mean with the task id. Are there any side effects to that?

#

(just curious)

ivory sleet
#

No not really

#

It’s just an AtomicInteger iirc

patent horizon
#

how do i spawn a client sided entity with protocol support?

mortal hare
ivory sleet
granite beacon
#

very true

patent horizon
#

oh

#

it's a server thing?

mortal hare
#

not the client to the server

patent horizon
#

but i thought the client was per-player and server was global players

#

why would the server handle an entity only one person's client sees?

mortal hare
#

that's not how servers work. To get clientsided rendering of an entity

#

server needs to send the packet

#

to specific player

#

in order for server to display all entities in the world

#

it sends packets to player's client every tick

#

a.k.a 1/20 second

patent horizon
#

ah ok

mortal hare
#

but yes, you can send the packet manually

patent horizon
#

would that mean i need to make a repeated task in order to spawn the entity and then to keep it alive and do things afterwards?

mortal hare
#

no

#

has you covered for this

patent horizon
#

so i can just spawn a fake entity for the player, and it'll just wander around like normal ai?

mortal hare
#

no it wouldnt

#

AI pathfinding is controlled by the server

patent horizon
#

ah

mortal hare
#

you're only sending the packet

#

the incorrect server packet

patent horizon
#

and the entity stays there until updated?

mortal hare
#

client believes it that its from server and its true

#

client renders it

#

AI pathfinding system on server, it sends
positions packets back to the client

#

AI is not done on clientside

#

you can test that by lagging yourself out in a server

#

not any mob would move

#

nor do the sounds

patent horizon
#

right

#

how would i then remove the entity?

mortal hare
#

you're basically sending data back to the client without server noticing it and verifying it

#

you're bypassing the whole server processing

#

For removing entity from the client screen

#

there's Entity Destroy packet

#

which when sent deletes mob from player's screen

patent horizon
#

it would just delete it right?

#

not do the kill animation

mortal hare
#

yes

#

just poof

#

and its gone

patent horizon
#

alr that's better in my case

mortal hare
#

In order to do animations

#

there's separate packet

#

when player or mob has been killed server sends animation packets back

#

to inform client that animation needs to be done since on server a entity has died

#

most of the data about the game is stored on the server

#

client mostly does the rendering

#

and positioning

patent horizon
#

so uh in my case, im trying to make it look like a fishing rod is being thrown from a carrot on a stick

#

does this packet count as an entity when using the entity spawn packet?

mortal hare
#

it should

#

there's a website

#

which tells you more about minecraft's protocol

#

go to Current Protocol Specification and see the packet you want for yourself

#

yes you can spawn fishing hook

#

by using Spawn Entity packet

#

im not sure if it includes the rendering of the string

autumn hound
#

is there any way to convert a cachedservericon to a bufferedimage?

patent horizon
#

in bukkit, you have to specify an owner public EntityFishingHook(World world, EntityHuman entityhuman) {

#

and i guess they also use the owners facing direction for hook velo and such

mortal hare
#

Every entity has its own ID

#

persistent between client and server

#

EID

#

not UUID

quaint bough
#

https://prnt.sc/1you9d8
This method registers goalSelector of entity villager what is the number parameter for this method im not sure what it does

patent horizon
#

but i was hoping protocol had support for what i wanted to achieve in nms

#

maybe i have to specify the owner afterwards or smth

#
PacketContainer fakeExplosion = protocolManager.
        createPacket(PacketType.Play.Server.EXPLOSION);

fakeExplosion.getDoubles().
    write(0, player.getLocation().getX()).
    write(1, player.getLocation().getY()).
    write(2, player.getLocation().getZ());
fakeExplosion.getFloat().write(0, 3.0F);```
similar to this
mortal hare
#

im pretty sure I saw on youtube how to spawn fishing hook with string via NMS

patent horizon
#

rlly?

#

that would be awesome to see

quaint bough
mortal hare
#

i cant find it

#

but its at least couple years old

#

and i think it was german

#

coding it

patent horizon
#

lmao

mortal hare
#

what he did is he pulled up the fishing rod class

#

and there's i think a method

#

to spawn the grappling hook

#

he just used the reflection to get that private method

#

and utilised it

lean gull
#

how do i make a custom skull item from nbt? like from the heads db api

sharp bough
#

tf is this new "theres a better way of doing it " thing

#

ahahahhaah

#

theres always a better way of doing anything

patent horizon
# lean gull how do i make a custom skull item from nbt? like from the heads db api
    public static ItemStack createSkull(String value) {

        String url = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUv" + value;

        ItemStack head = new ItemStack(Material.PLAYER_HEAD);
        if (url.isEmpty()) return head;

        SkullMeta headMeta = (SkullMeta) head.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        profile.getProperties().put("textures", new Property("textures", url));

        try {
            Field profileField = headMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(headMeta, profile);
        } catch (IllegalArgumentException | NoSuchFieldException | SecurityException | IllegalAccessException error) {
            error.printStackTrace();
        }
        head.setItemMeta(headMeta);
        return head;
        
    }```

basically go to custom heads website, go all the way down until you see the "value" field and paste that into the parameter for this method
#

it'll return your head as an itemstack

vestal matrix
#

how to i enable the arms of an armor stand? i dont see anything on the intellij tabcomplete i see stuff like setGravity but nothing for arms or baseplate?

patent horizon
#

those are really more living entity attributes

#

you have to actually set the nbt of the living entity to show arms

young knoll
#

What, no

patent horizon
#

well idk

#

oh wait no im dumb

patent horizon
#

show arms will be inside of ArmorStand

#

yeah

vestal matrix
#

Cannot resolve method 'setArms' in 'Entity'

patent horizon
#

read plz

vestal matrix
#

what

young knoll
#

Entity is not armorstand

vestal matrix
#

oh wait i just realised i was using entity instead of armor stand

patent horizon
#
        LivingEntity armorStandEntity = (LivingEntity) Bukkit.getWorld("your_world").spawnEntity(location, EntityType.ARMOR_STAND);
        ArmorStand armorStand = (ArmorStand) armorStandEntity;
        armorStand.setArms(true);```
vestal matrix
#

mb

patent horizon
#

yuppers

#

actually you can even do

#
        LivingEntity armorStandEntity = (LivingEntity) Bukkit.getWorld("your_world").spawnEntity(location, EntityType.ARMOR_STAND);
        (ArmorStand) armorStandEntity.setArms(true);```
vestal matrix
#

alright thanks

patent horizon
#

does anyone have an example of sending server nms packets to a player

young knoll
#

Even better,
ArmorStand armorstand = world.spawn(location, ArmorStand.class)

patent horizon
#

how am i supposed to know which letters correspond to which parameters?

#

doesnt seem to say in the wiki, unlike the tutorial im watching

#
    public PacketPlayOutSpawnEntity(int var0, UUID var1, double var2, double var4, double var6, float var8, float var9, EntityTypes<?> var10, int var11, Vec3D var12) {
        this.c = var0;
        this.d = var1;
        this.e = var2;
        this.f = var4;
        this.g = var6;
        this.k = MathHelper.d(var8 * 256.0F / 360.0F);
        this.l = MathHelper.d(var9 * 256.0F / 360.0F);
        this.m = var10;
        this.n = var11;
        this.h = (int)(MathHelper.a(var12.b, -3.9D, 3.9D) * 8000.0D);
        this.i = (int)(MathHelper.a(var12.c, -3.9D, 3.9D) * 8000.0D);
        this.j = (int)(MathHelper.a(var12.d, -3.9D, 3.9D) * 8000.0D);
    }```
young knoll
#

Use the remapped jar

#

Or get used to digging through obfuscated stuff

formal dome
#

what is this plugin object?

#

plugin.saveDefaultConfig();

drowsy helm
#

your main class which extends JavaPlugin

formal dome
drowsy helm
#

yep

formal dome
#

oh ok

formal dome
drowsy helm
#

show ur code

formal dome
#
public class BroadcastReader extends JavaPlugin implements Listener {

    public File config;
    public Socket clientSocket;
    public PrintWriter out;

    @Override
    public void onEnable() {

        BroadcastReader.getProvidingPlugin().saveDefaultConfig();

        try {
            clientSocket = new Socket("ip", 8080);
            out = new PrintWriter(clientSocket.getOutputStream(), true);
        } catch (IOException e) {
            e.printStackTrace();
        }

        config = new File(getDataFolder(), "src/main/resources/config.yml");
            if(!config.exists()){
                config.getParentFile().mkdirs();
                saveResource("src/main/resources/config.yml", false);
            }

        getServer().getPluginManager().registerEvents(this, this);


    }```
drowsy helm
#

whats the whole BroadcastReader.getProvidingPlugin()

formal dome
drowsy helm
#

saveDefaultConfig() is a method of JavaPlugin

#

just call it

formal dome
#

it's not static

drowsy helm
#

it doesn't need to be static

formal dome
#

oh

#

ok

#

sorry

drowsy helm
#

all you need to do is saveDefaultConfig() i think you're confused that you need an instance reference

formal dome
#

yeah i figured it out lol

young knoll
#

I mean you can use this if you really want to have an instance reference

formal dome
#

nah i don't

#

i forgot that its inheriting all the methods so i can just call it lol

#

since it's a function of the class now

#

question, what's the usual way of updating config files other than manually changnig it

#

is there a way to do it from the server instance

#

like an initial setup screen in the server... maybe a slash command that sets it up

young knoll
#

Nope

#

The usual method is to read the one in the jar and the one on the server, copy any missing fields from jar to server

#

Of course if you change fields that doesn’t quite work

autumn hound
#

is there any way to convert a cachedservericon to a bufferedimage?

odd lichen
#

Custom enchantments and effects on a pickaxe while player is holding: looping through enchantments on pick and doing ABC...

One repeating task that loops through all players and checks if player is holding certain item and do something
OR
One repeating task per player that does so.

My main concern is with lag spikes when the repeating task is ran, and my thought process is to use per player tasks which means that the tasks are ran at a more sporadic interval.

Any thoughts would be appreciated.

young knoll
#

Depends how frequent it is

odd lichen
#

every 15secs

young knoll
#

A good option is to run a task every say, 3 seconds and process 20% of online players each time

hybrid spoke
#

unnecressary. as long as you are not doing anything blocking it should be totally fine

mortal hare
#

ah yes

#

Sodium renderer is great

chrome beacon
#

👀

mortal hare
#

it rains in snowmen

dry forum
#

i have an api in my plugin that uses public classes and voids and all that but how am i supose to let other people use it in their plugin's library? i tried adding it to a new project and i did ApiTest at = new ApiTest(this); and where it says this, it says it needs to be the exact same main path as my api project so lets say in my api class my main class path was com.stuff.main the main path on the other plugin would need to be that as well

drowsy helm
#

did you import the jar

dry forum
#

yeah its added as a library

drowsy helm
#

is your api an actual plugin itself?

dry forum
#

yeah

drowsy helm
#

well you cant instantiate a plugin

#

you have to have another way to access it

dry forum
#

what

#

its not on my server or anything im just trying to test the methods in another plugin

ivory sleet
#

An api is just a set of interfaces you internally implement, then you expose them through services manager.

mortal hare
#

what you can do

#

is to get the plugin instance via pluginmanager

#

and cast it to the class of library plugin

quaint mantle
#

I've heard there's some sort of service manager in bukkit or smth

mortal hare
#
MyLibrary library = (MyLibrary)server.getPlugin("MyLibrary");
lost matrix
mortal hare
#

im surprised that the library doesnt provide a static accessor

#

or service api

#

majority of API's on spigot include static getter method to get the instance of the library plugin

#

iirc WorldGuard or WorldEdit uses service api

lost matrix
mortal hare
quaint mantle
#

Ah

#

I thought this guy made his own api

lost matrix
craggy cosmosBOT
#

:dynoError: The Fun module is disabled in this server.

sudden pollen
#

You cannot have fun here.

summer scroll
#

Is using abstract/interface class considered as using inheritance concept?

quaint mantle
#

😂

noble lantern
#

For BlockPlaceEvent#getItemInHand()

Is the item in hand the block that was placed? EG: If they place blocks in offhand, it gets the block in the offhand, and if its in main hand it gets it in main hand?

summer scroll
noble lantern
#

1.16+ only

quaint mantle
noble lantern
#

Maybe will do 1.13 but not sure yet

summer scroll
noble lantern
quaint mantle
summer scroll
#

If you want to get the information from the ItemStack, you could detect the hand.

#

You could try tho.

#

The BlockPlaceEvent#getItemInHand

noble lantern
#

Yeah cant hurt to try ofc was just curious before trying it or wether i had to do some jank stuff between events to get item in hand xD

summer scroll
quaint mantle
#

Any extra details? You have triangle class that, maybe, extends Shape?

summer scroll
#

That's what I'm thinking right now, but I don't know what to put on the Shape class.

#

No extra details, literally that's it.

quaint mantle
#

Hm, make it abstrsact and make an abstrsact calculateArea method on it. Then, make Triangle extend Shape and implement the method

#

Thats clearly polymorphism, but..

summer scroll
#

haha

#

ik it's only overcomplicating a simple thing but it's still a task

lost matrix
summer scroll
drowsy helm
summer scroll
#

inheritance as a concept of oop

drowsy helm
#

abstract method just has to be overriden on the class extending it

drowsy helm
#

ah mb

lost matrix
#

Circle extends/implements Shape and thereby inherits the method calculateShape() from Shape

drowsy helm
#

yeah abstraction is inheritance

#

hey smile havent seen you here for a while

lost matrix
summer scroll
#

Like this I guess lmao

public abstract class Shape {
    public abstract double calculateArea();
    public abstract double calculateVolume();
}

public class Triangle extends Shape{
    private double base, height;
    public Triangle(double base, double height){
        this.base = base;
        this.height = height;
    }
    @Override
    public double calculateArea() {
        return 0.5 * base * height;
    }
    @Override
    public double calculateVolume() {
        throw new UnsupportedOperationException("This shape doesn't support this method!");
    }
}
lost matrix
#

Make the abstract class an interface

#

Abstract class only makes sense if you have a state

summer scroll
#

alright

#

thanks

quaint mantle
chrome beacon
lean gull
#

no error, just the logger saying that it couldn't create it

#

even though it did make it but without anything inside it

chrome beacon
#

Get the error you're hiding it with try catch

hybrid spoke
#

where do you place your abstract methods in your abstract class personally?

lost matrix
hybrid spoke
quaint mantle
#

Yeah, same

lost matrix
# hybrid spoke so under everything else?

public static var
private static var
public static method
private static method
public field
private field
constructor
public method
private method
public abstract method
protected abstract method

this is what i do currently

chrome beacon
#

In the try catch tell it to print the error

#

It's that simple

lean gull
#

idk how to do that

chrome beacon
#

Intellij should already do it for you

#

(When you tell it to add try catch)

quaint mantle
#

how to have it..?

lean gull
#

this? idk i'm just guessing
plugin.getLogger().info(e.getMessage());

lean gull
#

go on the settings and search for font

lost matrix
# lean gull

You just need to catch the IOException. What you do in your catch block is irrelevant.

lean gull
#

what does that mean

lost matrix
#

You can take that literally.
try { Code } catch(IOException e) { Handle exception }

lean gull
#

??

lost matrix
lean gull
#

this doesn't say how to send the error

lost matrix
#

Use
Exception#printStackTrace()

lean gull
quaint mantle
#

?learnjava

undone axleBOT
quaint mantle
#

maybe consider doing that?

lean gull
#

maybe consider not being toxic?

quaint mantle
#

maybe consider thinking again?

lost matrix
lean gull
#

yeah, and?

#

where am i supposed to specify a path

lost matrix
#

DuckDuckGo what this exception could mean and why it occurs.

lean gull
#

i don't understand

#

does it mean my path in enivoronment variables is incorrect or something?

lost matrix
quasi flint
#

mkDirs();

lean gull
#

isn't that this?

    public void createTabConfig() {
        if (plugin.getDataFolder().exists()) {
            plugin.getDataFolder().mkdir();
        }```
quasi flint
#

mkdir only creates the bottom most file

lost matrix
#

If my folder already exists: Create the folder <= Thats what you are doing

quasi flint
#

mkdirs create all of em

#

make mkdir to mkdirs and ! in front of the top most if statement

drowsy helm
quasi flint
lean gull
#

ok, so i fixed the config manager thing, but now it doesn't set anything inside it?

lost matrix
#

"it"...

quasi flint
#

whats it?

lean gull
#

like the tabmanager class does not set anything inside the tab config file

quasi flint
#

why should it?

lean gull
#

that's what it's supposed to do

quasi flint
#

does it get called / executed?

lean gull
#

yes

quasi flint
#

show code

drowsy helm
#

can we see some code

lean gull
#

nvm im a dum dum

#

my b

drowsy helm
#

lol

quasi flint
#

hey fixed it

lean gull
#

wait no, i'm not

quasi flint
#

show code

lean gull
#

TabManager class:

    public void TabManager() {
        cfgm = new ConfigManager();
        cfgm.reloadTab();
        FileConfiguration tabConfigFile = cfgm.getTab();
        tabConfigFile.set("banana", "yes");
        cfgm.saveTab();
    }```
Main class in onEnable:
`TabManager tab = new TabManager();`
quasi flint
#

executed before file is created?

#

or after??

lean gull
#

after

quasi flint
#

show saveTab, reloadTab method

lean gull
#

it says that tab in main and TabManager in TabManager class is not used

quasi flint
#

well u are not callin it then

lean gull
#

by calling tabmanager i am calling it tho?

drowsy helm
#

can we see configmanager

lean gull
#

from what i know, if you have a method named after your class it is run when you call that class

drowsy helm
#

the constructor

#

yes

quasi flint
#

Show the whole class

drowsy helm
#

well its called when you create the class

quasi flint
#

?paste

undone axleBOT
quasi flint
#

fucking phone

lean gull
quasi flint
#

ConfigManager class

#

U Donut

lean gull
#

but this has nothing to do with the config manager class

quasi flint
#

it may does

drowsy helm
#

it has everything to do with it lol

quasi flint
#

when it doesnt save changes

lean gull
#

it creates the folder and the file, it's just that the tab thing is not used for some reason

quasi flint
drowsy helm
#

from the limited code you've sent there doesn't seem to be any reason for it not to work

#

so we have to see every aspect

quasi flint
#

true shit my g

lean gull
#

intellij is telling me that TabManager method in TabManager class is unused along with tab variable in the main class

quasi flint
#

because why should u use it

drowsy helm
#

oh

quasi flint
#

u run the class

drowsy helm
#

if you want a constructor

#

it has no void

#

just public TabManager()

quasi flint
#

ah shit

#

here we go again

#

?learnjava

undone axleBOT
lean gull
quasi flint
#

make ur tabmanager class not void

#

public TabManager()

#

not void

#

thats it

lean gull
#

ok, thanks

tender shard
#

yo everyone, what JVM are you using for MC 1.17?

#

I'm on debian 11 btw

quasi flint
#

this shit dev channel

#

my g

tender shard
#

oh yeah

#

sorry mb I wanted to go to help-server

quasi flint
#

np

lost matrix
#

Current LTS is 17

tender shard
#

yeah but

#

which one

#

adopt, oracle, openjdk, ...

quasi flint
#

adopt

tender shard
#

I heard goot things about graalvm

#

anyone ever used that?

drowsy helm
#

is there even a noticeable diff between jvms

ivory sleet
#

Isn’t that to run JavaScript on the jvm?

tender shard
#
#

it's a normal JDK

ivory sleet
#

Some have patches for certain things others are meant for debugging

tender shard
#

they claim to be about 10% faster than other JDKs but tbh 10% isn't that much

#

I'll probably just use the normal openjdk from Debian's official repos

drowsy helm
#

10% across the board?

#

damn

#

very bold

tender shard
ivory sleet
#

Would like to see some statistics on that :0

tender shard
#

I mean, I could also claim that my plugins are 8-11% better than other ones.... 😄

#

I don't believe them until there's some proof 😄

#

I'll just go with openjdk 17 for now which is included in debian anyway

lost matrix
tender shard
#

alrighty, thanks

#

@lost matrix

trail flume
#

Anyone know how these are done? This is on the OriginRealms (spigot, not modded) server. I know it's a resource pack but how exactly could I replicate this in code and in my resource pack?

humble heath
#

how do i get the player head to show the playes skin

trail flume
lean gull
trail flume
#

that's a good shout

lean gull
#

also i mean like to remove a bossbar texture, then add multiple bossbars set to unicode characters that are then textured in a font and aligned with the ascent thing

trail flume
#

yeah

#

is it possible to set a custom bossbar texture?

#

like with nms or something

humble heath
trail flume
#

hang on

#
SkullMeta meta = (SkullMeta) playerHead.getitemMeta();

skullMeta.setOwner(list.get(i).getDisplayName());
skullMeta.setDisplayName(list.get(i).getDisplayName())
ArrayList<String< lore = new ArrayList<>();
lore.add(Utilities.color("&6Health: &4" + list.get(i).getHealth()));
lore.add(Utilities.color("&6EXP: &4" + list.get(i).getExp()));
lore.add(Utilities.color("&Gamemode: &4" + list.get(i).getGameMode()));
meta.setLore(lore);

playerHead.setItemMeta((ItemMeta) meta);
```This should help
quasi flint
#

can u somehow move the player seemlesly?

#

prob velocity vectors right?

lean gull
trail flume
#

but how in code

stone sinew
trail flume
#

But they're not holograms... they're on the player's screen

humble heath
#

nope still nothing

lean gull
#

yapperyapps, i think commandcracker8 is asking on how to make bossbars

stone sinew
stone sinew
trail flume
#

How do I change the texture though

#

Of a bossbar

lean gull
#

for that you'll need to ask in a different discord server about fonts and textures

trail flume
#

ok

stone sinew
trail flume
#

How can I remove the bar?

#

is that possible

humble heath
#

it works now thank you

lean gull
#

wrong discord server bud

trail flume
#

its plugin dev but ok

stone sinew
#

If you modify the bars texture you can

lean gull
#

it's not, it's the texture

trail flume
#

ok

young knoll
#

Generally they use a font to show a custom texture

trail flume
#

im not entirely sure how I'd achieve that

lean gull
young knoll
#

It tells you file is null

lean gull
#

what does it mean though

young knoll
#

It means tabFile is null

lean gull
#

it made the file tho

pastel stag
#

?paste

undone axleBOT
pastel stag
#

can anyone spot my error? when i break a block that exists it removes the block but executes player.sendMessage(ChatColor.YELLOW + "[WATCHBLOCK B] Block was not protected.");

#

dont even understand how thats possible...

hybrid spoke
#

yeah lemme take my holy crystalball and clairvoyance what your methods do

paper viper
#

what does sqllogger

#

do

pastel stag
#

the methods do exactly what they're named to do blockexists just checks if the block exists in an sql database, removeblock removes it from the database

paper viper
#

maybe something changed in the database

#

when you try calling it again

pastel stag
#

the only explanation here is that something else is removing it right?

hybrid spoke
#

we would need to see what your methods do to help you

#

otherwise we can just speculate

slim kernel
#

How can I send a video in here?

hybrid spoke
#

drag n drop

#

otherwise a link

slim kernel
#

Hello!
I am making Spheres with Particles by rightClicking. If I rightClick again the radius gets bigger. By pressing left click I can "shoot" the sphere by moving the center. Everything functions right with the small radius. However, once I shoot the middle or the big one, everything goes right until it should stop. The Runnable doesnt stop then it just starts from the top again although "done" is true. Pls help me I cant find the error.
SphereTask:
https://gist.github.com/ItzJustNico/e72aeba7fee0d2f1a73b7b6713ad3610
LimitedTask:
https://gist.github.com/ItzJustNico/9a11703152f9ee3e7d4c4ab0c3bc5ec1
LimitedTaskRunnable:
https://gist.github.com/ItzJustNico/1eb3c1e006a9d561165722bf75543212

hybrid spoke
#

remove those embeds

slim kernel
hybrid spoke
#

seems like you never cancel the scheduler

slim kernel
hybrid spoke
# slim kernel

so you mean because it needs a sec to fade out or what

slim kernel
#

Yeah you can see by the debugs in the chat that done is already true and it should stop but it doesnt then it starts again and spawns a sphere again after the explosion @hybrid spoke

#

When I do the small one I get done in the chat and it stops as it should

hybrid spoke
#

there is so much boilerplate code

slim kernel
mortal hare
#

i fear no man... but that thing:

#
java.util.ConcurrentModificationException: null
        at java.util.HashMap$HashIterator.nextNode(HashMap.java:1584) ~[?:?]
        at java.util.HashMap$KeyIterator.next(HashMap.java:1607) ~[?:?]
#

it scares me

hybrid spoke
slim kernel
#

After the "true" "done" "true" it should be finished. But the there is the "false" again which means it started again somehow and done is "false" again @hybrid spoke

slim kernel
hybrid spoke
#

i guess you are starting it over and over again

#

with your rightclicks

humble heath
#

how do i check to make shour that it is a player head that someone is clicking

hybrid spoke
hybrid spoke
slim kernel
hybrid spoke
slim kernel
slim kernel
slim kernel
lean gull
humble heath
#

might help to register the events in the main class