#help-development

1 messages · Page 1752 of 1

dark osprey
#

yes. you need check

verbal nymph
#

Because I dont think it does

coral heron
#

you are casting to the player so yes in that case please check if the entity is an instance of the player

#

java's instanceof keyword helps

verbal nymph
#

Nevermind it's inside of the PlayerDeathEvent .
This is the relevant code:

public void onPlayerDeath(PlayerDeathEvent e) {
        var player = e.getEntity().getPlayer();
        boolean isPvpDeath = player.getKiller() != null;
        // ...
}
dark osprey
#

kotlin ok

verbal nymph
#

Can this really throw an NPE? Because I don't think it ever has

dark osprey
#

yes. it can possible throw an NPE.

verbal nymph
#

In what situation would that happen?

dark osprey
#

Depending on your code, that error may occur. However, it is recommended to check for null.

verbal nymph
#

But does PlayerDeathEvent fire for any non-player entities dying?

dark osprey
#

no.

#

only player death.

verbal nymph
#

Ok but then how can it throw an NPE?

dark osprey
#

i told you

verbal nymph
#

You said depending on my code it may occur. But I'm literally just getting the entity from the event. And you said the event only fires for players.

coral heron
verbal nymph
#

I only checked the docs. But Vaget said there are occasions when an NPE may be produced here, I'm just wondering what they meant

sharp hemlock
#

It's because you're getting a player from an entity

#

So it won't occur under that event

verbal nymph
tardy delta
#

is it possible to convert a Map<UUID, ItemStack[]> to a List<String>? i can get the string with the base64 converter but it doesnt really works for collecting it

lost matrix
tardy delta
#

nah i just want to have a list with strings

#

something with foreach

#

so i can get the uuid too

coral heron
#

bruh just create a new list and add your strings there with a foreach

#

ArrayList is good

tardy delta
#

isnt it possible with a stream?

tidal hollow
#

How can I make a command that tells you how many totems you used? example: Server - Used Totems: 1

coral heron
tardy delta
#

something like

dataFile.set("safe-chests", SafechestGui.getMenus().entrySet().stream().map(entry -> InventorySerialisation::itemStackArrayToBase64).collect(Collectors.toList()));
#

i think i got it

lost matrix
# tardy delta something like ```java dataFile.set("safe-chests", SafechestGui.getMenus().entry...
  private final Map<UUID, ItemStack[]> items = new HashMap<>();

  public void writeToConfig(final FileConfiguration configuration, final String key) {
    final ConfigurationSection section = configuration.createSection(key);
    for (final Entry<UUID, ItemStack[]> entry : this.items.entrySet()) {
      section.set(entry.getKey().toString(), Arrays.asList(entry.getValue()));
    }
  }

  public void readFromConfig(final FileConfiguration configuration, final String key) {
    final ConfigurationSection section = configuration.getConfigurationSection(key);
    if (section == null) {
      return;
    }
    for (final String uidKey : section.getKeys(false)) {
      final UUID userID = UUID.fromString(uidKey);
      final List<ItemStack> itemStackList = (List<ItemStack>) section.getList(uidKey);
      this.items.put(userID, itemStackList.toArray(new ItemStack[0]));
    }
  }

You can just save a List<ItemStack> in a config path.

tardy delta
#

heh ```java
dataFile.set("safe-chests", SafechestGui.getMenus().values().stream().map(InventorySerialisation::itemStackArrayToBase64).collect(Collectors.toList()));

#

also how can i get a Player object from an uuid?

#

Bukkit.getPlayer(uuid) will return null i guess

coral heron
rough jay
tardy delta
#

so the player will not be null?

young knoll
#

It will be null if they aren’t online

tardy delta
#

well i want to get a player object from offline players :/

young knoll
#

You can’t

#

A player object represents an online player

tardy delta
#

hmm

ancient plank
#

offlineplayer represents an offline player ThumbsUpSmile

tardy delta
#

in the playerjoinevent, the player is "online" right?

ivory sleet
#

🧠

rough jay
#

please could anyone help me? 🙏

opal juniper
#

yes

tardy delta
#

yesh

coral heron
#
    private HashMap<UUID, Integer> balance = new HashMap<UUID, Integer>();
    private HashMap<UUID, Boolean> joinedPlayer = new HashMap<UUID, Boolean>();
    private HashMap<UUID, Boolean> mutedPlayer = new HashMap<UUID, Boolean>();
    private HashMap<UUID, String> mutedReason = new HashMap<UUID, String>();
    private HashMap<UUID, Boolean> nickedPlayer = new HashMap<UUID, Boolean>();
    private HashMap<UUID, String> playerNickname = new HashMap<UUID, String>();
    private HashMap<UUID, String> playerTeam = new HashMap<UUID, String>();
    private HashMap<UUID, Boolean> socialSpy = new HashMap<UUID, Boolean>();
    private HashMap<UUID, Boolean> teamChat = new HashMap<UUID, Boolean>();
ivory sleet
#

holy cow

coral heron
#

so.... wouldn't it be easier if you made this a single class and just had one hashmap?

opal juniper
#

Yes

ancient plank
#

that's a lot of hashmaps

opal juniper
#

lol that entire classes just hashmaps, getters and setters

coral heron
#

YES

#

apparently

eternal oxide
#

What they are saying is, theres much better ways to handle all of that

lost matrix
#
  private final Map<UUID, PlayerData>
tardy delta
#
public void addBalanceToPlayer(OfflinePlayer p, int amount) {
        if (balance.get(p.getUniqueId()) != null) {
            balance.put(p.getUniqueId(), balance.get(p.getUniqueId()) + amount);
        } else {
            balance.put(p.getUniqueId(), amount);
        }
    }

use this instead

public void addBalanceToPlayer(OfflinePlayer player, int amount) {
  balance.putIfAbsent(player.getUniqueId(), amount);

}

tardy delta
coral heron
tardy delta
#

also those hashmaps...

tardy delta
#

maybe a database or yml woild be better

opal juniper
#

So you need to make a counter

#

check the players hands for a totem if the event is not cancelled

#

if there is a totem present, increment a counter

ivory sleet
opal juniper
#

then just query it on command

rough jay
#

pdc?

young knoll
#

How on earth is there not a statistic for that

opal juniper
#

?pdc

young knoll
#

Dangit Mojang

opal juniper
tardy delta
ivory sleet
tardy delta
#

who even said me to use uuid in the chunk pdc smh

rough jay
#

so if I don't use pdc what do I use?

opal juniper
#

youd have to manually save / read to file

tardy delta
#

probably yml then

#

😳

rough jay
#

well now I'm grouping all HashMaps into 1 class

coral heron
rough jay
#

yeah

#

like this

public class Maps {
    private final HashMap<UUID, PlayerData> playerDataMap = new HashMap<UUID, PlayerData>();
    public MaxiCity plugin;

    public Maps(MaxiCity plugin) {
        this.plugin = plugin;
    }

    public static class PlayerData {
        private Integer balance;
        private Boolean hasPlayerJoined;
        private Boolean isPlayerMuted;
        private String mutedReason;
        private Boolean isPlayerNicked;
        private String playerNickname;
        private String playerTeam;
        private Boolean socialSpy;
        private Boolean teamChat;
    }
}
ivory sleet
#

you presumably want to use primitive data types over the boxed ones

#

so use int instead of Integer and boolean instead of Boolean

rough jay
#

ok

#

and how do I get the balance or any field from playerDataMap?

ivory sleet
#

you create a getter

#

in PlayerData create a method like:
public int getBalance() {
return this.balance;
}

coral heron
tardy delta
#

lol

rough jay
#

thx now all I need to do is the save/load from a file

tardy delta
#

mutedReason: the reason why the reason is muted

coral heron
#

or not?

rough jay
#

lol

#

mutedReason is the reason why the player is muted

acoustic pendant
#

Hello! i'm trying to get a constructor from a class in other class with instances, but getting an error...

    private final CriticalHits plugin;

    public CritCancell(DamageIndicator plugin) {
        this.plugin = plugin;
    }

I have this in the class where i want to access, and this in the other class:

    private final DamageIndicator plugin;

    public CriticalHits(DamageIndicator plugin) {
        this.plugin = plugin;
    }

(DamageIndicator is the main class...)

rough jay
acoustic pendant
ivory sleet
#

well you'd call something like
playerDataMap.get(uuid).getBalance() for instance

rough jay
#

Cannot resolve method 'getBalance' in 'UUID'

waxen barn
#

Hi there, sorry for stupid questions, but is there some way how to get the correct namespaced key of a custom biome instead of just minecraft:custom in 1.17.1?

tardy delta
ivory sleet
#

oh you're not suppose to call uuid.getBalance()

rough jay
#

oh

#

lol

#

yeah I saw the mistake lol

tardy delta
coral heron
keen gate
acoustic pendant
keen gate
#

You didn't assign a value to them, so they're null

acoustic pendant
#

but, don't know how to solve it :/

coral heron
pseudo sky
#

so guys iam backing try make spigot plugins, i tyred on 1.6.4 with gradle, but for some reason i cant extend JavaPlugin

#
runtimeOnly files('libs/spigot-1.6.4-R2.1-SNAPSHOT.jar')
ivory sleet
#

compileOnly

rough jay
pseudo sky
#

NVM

#

fixed

coral heron
lost matrix
pseudo sky
rough jay
coral heron
acoustic widget
#

Hello is better to use Persistent Data Container from spigot api or database for store many things on users ? What do you think ?

ivory sleet
#

I'd say depends

#

the data becomes somewhat too coupled with spigot arguably

#

I used it for certain statistics like totem uses etc

#

but when it comes to non bukkit related data like permissions, economy etc I believe using another storage implementation is much more beneficial

rough jay
pseudo sky
#

okie that is new

#

👀

eternal oxide
#

no import

pseudo sky
#

i did lmao

eternal oxide
#

theres no import in that screenshot

quaint mantle
#

its same package

opal juniper
#

it’s registerEvents

pseudo sky
opal juniper
#

not Event

#

plural

pseudo sky
#

question, can i detect a MOD event using spigot or no?

#

or i will need forge for that?

chrome beacon
#

Spigot doesn't support mods

pseudo sky
#

okie thx

chrome beacon
#

And Forge doesn't support plugins

rough jay
burnt hamlet
#

does anybody use a vanilla weapons plugin that works for java and bedrock servers? it would add axes, katanas, daggers. also armor if possible. very few to 0 added ores.

chrome beacon
#

Wrong channel

quasi flint
#

I think U need Mods for that

chrome beacon
#

Stay in help server

mortal hare
#

Anyone know how to create PacketDataSerializer from scratch

#

constructor requires ByteBuf

#

but PacketDataSerializer is itself the extension of the netty AbstractByteBuf class

tame elbow
#

find players near mob inside creaturespawnevent listener

rancid pine
#

how can I use the worldcreator to make a world with no blocks, only air

chrome beacon
#

Start by creating a chunk generator

rancid pine
crude sleet
#

Is there a possibility to add a separate recipe category for the recipe book? I want that my friends have a good overview of my own recipes

rancid pine
#

what class should I look at?

bronze elbow
#

Someone tell me how to do that when someone moves for a while die?

coral heron
#

/fill ?

young knoll
#

Nested loops

opal juniper
young knoll
#

I mean you could run the fill command from code

#

But like, don't

hardy agate
#

I'm trying to make variables in vanilla minecraft. The idea is I could take this command:

give @s $varible 64

then, send that command to a custom parser that I would build, and replace $variable with whatever it's value (say, minecraft:stone). Then, after replacing the variable names with their values, run the newly parsed command as the sender.

Bukkit.dispatchCommand(p, parsedCmd);
// would essentially run "give @s minecraft:stone 64"

My question is: How do I intercept the command before the game parses it?

young knoll
#

No idea if that runs for console commands

hardy agate
#

is that an onEvent?

#

for player sending a command?

young knoll
#

mhm

hardy agate
#

or does that give me the command first, that I can manipulate and then send on it's way

young knoll
#

Read the docs

hardy agate
#

ok thank you!

eternal oxide
#

BlockExplode is only when teh block itself is the source of the explosion

#

PrimedTNT is an entity

#

what are you trying to do?

#

then listen to the Entity explode event

trail flume
#

I'm using NMS and my custom entity instantly disappears, what am I doing wrong?

rotund pond
#

Hello everyone !

I have a little question:

For some reason I use this method which allows me to force a player to execute a command.

Bukkit.dispatchCommand(player, "warp test");

The problem is that this system triggers Spigot's permission system.
I would like to know if it is possible to bypass the permissions plugin please?

trail flume
#

NMS Entity Disappearing

chrome beacon
young knoll
#

Generally that is the way plguins like citizens do it

#

Alternatively get a plugin that supports /warp player name

rotund pond
#

I see ...
I'm a bit sad

chrome beacon
#

Well does the if check pass

#

What event is event

eternal oxide
#

You can't change the blocks in the explode event. They are going to be removed and it finishes

#

what are you trying to do? Your code is nto clear

#

you have a copy of the area at +1000 x?

#

why?

#

ok, you need to run a task in the explode event, delayed...

#

you pass it the list of blocks

#

then when the task executes you copy from the reset map to the main map

#

yes

turbid oasis
#

what

#

do u know how to apply a custom texture to a player skull?

#

I just cant figure it out.

young knoll
#

You want to instantly restore blocks that get blown up?

#

Just remove any block that isn't in the resetmap from event.blockList

#

Use an iterator on event.blockList()

#

and call remove() if they aren't in the resetmap

golden turret
#

?paste

undone axleBOT
golden turret
#

when i do map.values and use stream, they lost the ordering

#

using treemap

mortal hare
#

dispatching command for this seems like a code smell for me

mortal hare
#

is warp command from the EssentialsX?

rotund pond
mortal hare
#

Have anyone used PacketDataSerializer before

#

i really struggle with this

#

right now

hardy agate
#

I'm trying to store data to a file, so that it won't reset when I restart. Can anyone point me to a good resource to help?

eternal oxide
#

What data are you trying to store?

quaint mantle
#

hello, i want to break wood with pickaxe, faster. Any ideas ?

#

maybe set block hardness ?

hardy agate
lavish hemlock
#

I saw this one blog post by one of WorldEdit's contributors

eternal oxide
#

yeah, that tells me nothing, everything is a variable

lavish hemlock
#

basically it said that, if you have information that ALL must be known at the start of the plugin, it should be saved locally via YAML/GSON/whatever

#

otherwise, if you have a lot of information and you only need some of it at a time, use databases

hardy agate
#

what is optimal?

#

YAML or GSON

quaint mantle
#

GSON will be faster

#

but YAML will be easier

hardy agate
#

YAML it is lol

lavish hemlock
#

GSON's pretty easy tho

hardy agate
#

how much faster

#

like, noticeably if I'm not doing anything ridiculous?

eternal oxide
#

it all depends on what these "variables" are

quaint mantle
#

it sound like few ms

hardy agate
#

litterally just strings

#

at most an nbt dictionary

quaint mantle
#

yeah uses yaml

eternal oxide
#

just strings then GSON

hardy agate
#

ok getting two answers here

young knoll
#

Yaml isn't meant for data storage

hardy agate
#

it's used for config?

eternal oxide
#

oh an nbt dictionary, thats diffrent

lavish hemlock
#

I mean

#

you might be able to get away with txt/properties

hardy agate
#

not an nbt dictionary, but just a dictionary

#

actually, no

#

probably just strings and ints

eternal oxide
#

spigot has built in serialization for most bukkit objects

#

into yaml

hardy agate
#

yeah it's probably just strings and ints

quaint mantle
#

but in GSON you will got some problems like with locations or things like that

hardy agate
#

how so

quaint mantle
#

i create my own objects to serialize them

lavish hemlock
#

that javadoc is unconventional

quaint mantle
#

i know lol

#

boring

#

so boring

#

x)

lavish hemlock
#

Oracle's official guide says you shouldn't do "the world", "the x", etc. since it doesn't provide any additional information

quaint mantle
#

theme ?

lavish hemlock
#

it's quite colorful

quaint mantle
#

eww Intellij

lavish hemlock
quaint mantle
#

intelij >

lavish hemlock
#

there are basically no major issues with IntelliJ as far as I can tell :p

quaint mantle
#

Material Palenight

#

someone for my problem ?

lavish hemlock
#

you tried modifying the properties of the pickaxe?

quaint mantle
#

Material Theme UI

lavish hemlock
#

idk if it's possible for tool items but

quaint mantle
#

with attributes

mortal hare
#

Is there an easy way to desync player and the server for a little bit to test one thing

#

UDP flooder is all i can think of

lavish hemlock
#

How can I maintain compatibility across multiple versions (say, 1.8 -> 1.17.1) with Spigot's API?

#

Would I just need to declare a dependency on the minimum version I want to support?

young knoll
lavish hemlock
#

also: what is the minimum version worth supporting? I'm guessing either 1.8 (or else people will yell at you) or 1.13 (since it seems to be pretty stable, plus it means you don't have to deal with The Flattening)

young knoll
#

I would say 1.8 or 1.14

#

1.13 doesn't really run that well, the spigot API for it was only available for a short time, and 1.14 has PDC

lavish hemlock
#

ooh fair point

turbid oasis
#

How do I put a texture on a head?

jade perch
#

1.8 to 1.17 ez mode

lavish hemlock
#

oh yeah I remember XMaterial

#

how fast is it?

jade perch
#

I just compile it into materials at startup so I don't really have a metric for it

lavish hemlock
#

how'd you do that? custom code?

jade perch
#

Just what XMaterial does

lavish hemlock
#

oh

vague oracle
rough jay
#

yeah but what's the default value then?

prime reef
#

Can I fork Spigot and work on my own branch of it? I'm aware there's no support for that, but there are a few things I'm thinking about.

young knoll
#

Yes

proven whale
#

Execuse me

#

net.minecraft.world.level

#

In this package,there's an interface named IMaterial

#

I want to use it for net.minecraft.world.item.ItemStack

#

public ItemStack(IMaterial imaterial) {
this(imaterial, 1);
}

#

But I really don't know what is IMaterial

runic mesa
#

Currently im making a very simple home system, im using my player nbt data to store the coords and stuff i have that all working, how would i store my specific dimension in that? So if i set my home in the nether ill be able to have it send me to the nether location not all overworld

young knoll
#

Store the name or UUID of the world

runic mesa
young knoll
#

yes

hardy agate
#

config.yml help

quaint mantle
#

Is it possible to force a player to walk? Like not just tp but i mean make them walk to X location

#

I was looking for builtin methods via keywords like "walk" but cloest i found was walkspeed and frost walk stuff

#

I feel like I've done it before and seen a plugin do it but am having a total brain dead moment like its staring me in the face

quaint mantle
#

Thank you, its a bunny hole I'll start down at the least :)

proven whale
#

Execuse me
net.minecraft.world.level
In this package,there's an interface named IMaterial
I want to use it for net.minecraft.world.item.ItemStack
public ItemStack(IMaterial imaterial) {
this(imaterial, 1);
}
But I really don't know what is IMaterial

sullen marlin
#

Why

lavish hemlock
#

md_5, do you ever regret your life choices?

quaint mantle
#

no he is a millionare developer

#

he made minecraft

proven whale
#

What is Imaterial corresponding to a item

#

I do not well in English ,sorry

topaz cape
#

'i' stands for interface

eternal oxide
#

You use org.bukkit.Material not IMaterial

lavish hemlock
topaz cape
#

i was just wondering if i could upload a schematic file to a SQL database so i can load it on another server using hikaricp ofc (ping if it's possible :/)

turbid oasis
#

How can I use GameProfile?

eternal oxide
#

To use GameProfile, depend on spigot not spigot-api

unreal quartz
young knoll
#

Ah true

turbid oasis
eternal oxide
#

then it would not be a good idea to dive straight into using GameProfile

topaz cape
#

he prolly want to make a nick plugin or so

turbid oasis
#

oh ok

#

no im trying to make a custom skull texture

#

and it seems like you need GameProfile

topaz cape
#

uhh well, wouldn't advice going anywhere near that currently

turbid oasis
#

ok

topaz cape
#

till you learn more about spigot api and java itself

turbid oasis
#

ok

#

ill just get player heads instead

topaz cape
#

even better

proven whale
eternal oxide
#

then you are using teh wrong ItemStack/method

proven whale
#

I tried,But IJ said Required type:
IMaterial
Provided:
Material

topaz cape
#

sometimes i wonder how people come up with those things

eternal oxide
#

What are you trying to do?

proven whale
#

I'm trying to make new items through NBT

eternal oxide
#

why nbt?

#

spigot ItemStacks are new ItemStack(Material)

proven whale
#

But it doesn't provide a function which can add custom nbt

eternal oxide
#

ItemStacks now have a PDC

#

?pdc

proven whale
#

emmm

#

You have a point

#

I will try it ,thanks

eternal oxide
#

yes its possible

topaz cape
#

a statement .setobject?

#

i think that's the only way

eternal oxide
#

You could store it as a BLOB I guess

topaz cape
#

uh you are right but i think it could work faster if it's like that

#

could be wrong

#

i could have also done a gson.toJson

wind tulip
#

How would I go about making a 3-second countdown loop? (Before the minigame starts)

I've read about schedulers everywhere, but I still can't wrap my head around them

#

The plan is to sendTitle to all players as 3,2,1 but I don't know how to delay a loop.

willow widget
#

I have this:

            int offsetx[] = { 2, 2, -2, -2 };
            int offsetz[] = { 2, -2, 2, -2 };
            for (int i = 0; i < 4; i++) {
                Entity e = killer.getWorld().spawnEntity(new Location(killer.getWorld(), center.getX() + offsetx[i],
                        center.getY(), center.getZ() + offsetz[i]), entity.getType());
                e.setCustomName(General.colorize("&6Súbdito de Halloween"));
                e.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));
            }

Code (in a EntityDeathEvent) to spawn some mobs but I think their metadata is not being set because

if(event.getEntity().hasMetadata("EL_Halloween_minion"))

(in a CreatureSpawnEvent) is not being recognized as true 😦

#

if my full code for the events is needed lmk

young knoll
#

The creature spawn event runs as soon as you call spawnEntity

#

So, before the meta is applied

#

Use the version with a consumer to run stuff before it is spawned

willow widget
#

ohhh that makes sense yeah

#

ty

willow widget
eternal oxide
#

code that runs after teh thing is spawned, but before its placed in the world

willow widget
#

ok so I'd set the meta there, right?

eternal oxide
#

yes

willow widget
#

nice ty

#

oh wait but how do I point the meta to the entity created if it is being created in that line of code? xd

eternal oxide
#

thats what the consumer is for. use a lambda

willow widget
#

not that advanced into code heh

#

aka: idk how to use a lambda 😦

eternal oxide
#

mob -> { mob...}

willow widget
#

ok so...
event.getEntityType() -> {setmeta} ?

eternal oxide
#

no

willow widget
#

what's the first mob? lol

#

I undersstand that -> { set the meta } works like that

eternal oxide
#
mob -> {
   mob.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));
}```
willow widget
#

I just don't get the first mobthing

eternal oxide
#

exactly a typed

willow widget
#

ohhh lmao

#

mob as literally mob XD

#

so mob is a variable nice

eternal oxide
#

the mob thing is the thing you are spawning. Its passed into the lambda as mob

willow widget
#

yeah yeah nice

#

btw

#

do you know what the second arg in FixedMetadataValue is?
In the tutorial I followed it said it was an arbitrary value and I understood it doesn't matter but it kinda sounds useless to have a arg that "doesn't matter" lol

eternal oxide
#

its whatever value you want it to be

#

if you read teh meta you get back a List of MetaData

#

from each you can read teh value you set

willow widget
#

but isn't that the first arg in setMetadata()?

eternal oxide
#

no, thats the key

willow widget
#

oh

#

so key -> value

eternal oxide
#

yep

willow widget
#

nice ty again (:

eternal oxide
#

you just are not using the value

willow widget
#

yeah pretty much xd

#

but it is not a "doesn't matter" value, that's what I wanted to clear so I don't write dumb stuff lol

eternal oxide
#

yep, it could be anything, like a level of something

willow widget
#

yeah

#

nice

#

hehe

#

oh wait 😦

#

Error:

The method spawn(Location, Class<T>, Consumer<T>) in the type World is not applicable for the arguments (Location, EntityType, Consumer<T>)

Code:

killer.getWorld().spawn(new Location(killer.getWorld(), center.getX() + offsetx[i],
                        center.getY(), center.getZ() + offsetz[i]), entity.getType(), mob -> {
                               mob.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));
                        });

what did I do wrong? lol

eternal oxide
#

you need the mob class

#

like Creeper.class

willow widget
#

uhmmmm lemme see if I figure that out heh

#
killer.getWorld().spawn(new Location(killer.getWorld(), center.getX() + offsetx[i],
                        center.getY(), center.getZ() + offsetz[i]), entity.getType().getEntityClass(), mob -> {
                               mob.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));});

Nice 😎

#

That's right... right? hahaha

#

oh wait I pasted my previous clipboard lol

eternal oxide
#

there is a method on teh enum

willow widget
#

there, edited

eternal oxide
#

event.getType().getEntityClass()

willow widget
#

yeah

#

^^

#

I edited it

#

I pasted my old clipboard before idk why my pc didn't get the Ctrl+C xd

willow widget
proven whale
#

if(this.hasItemMeta()){ c_m = this.getItemMeta(); }else{ c_m = // there } c_m.getPersistentDataContainer().get(RunningMan.RM_ItemType, PersistentDataType.STRING);

#

how can I create a empty itemMeta

eternal oxide
#

Itemfactory

willow widget
# eternal oxide event.getType().getEntityClass()

yo I forgot hahaha
if World.spawn() "Creates a new entity at the given Location with the supplied function run before the entity is added to the world." then I'll have to manually spawn the entity? what would I use for that?

eternal oxide
#

no, that method spawns it

willow widget
willow widget
eternal oxide
#

yes

willow widget
next stratus
#

Is it possible to despawn / kill off a citizens api when the plugin stops? I can't work out how to do it 🤔

viscid cave
#

Anyone know why do my messages.yml is not imported.

quaint mantle
#

a big reccomendation to not use vscode for java

viscid cave
#

why?

quaint mantle
#

move to something like intellij and you'll love it 10x more

#

100x easier, use eclipse if you have a lower end pc

viscid cave
#

ok, i'll try it

subtle kite
#

How do you check if the player inv is full, because when you add a item. it just doesn't work if the player has a full inv.

fickle helm
quaint mantle
fickle helm
#

nice, gonna update my relatively primitive function with that one

young knoll
#

addItem should return a map of what it failed to add

#

Which you could then drop

viscid cave
quaint mantle
#

did you setup a JDK

viscid cave
proven whale
proven whale
#

ItemMeta
getItemMeta​(Material material)

#

this?

buoyant viper
#

the issue was where he was trying to read messages.yml from

quaint mantle
#

i know

#

im just reccomending it to him

buoyant viper
#

hm

quaint mantle
#

they shouldve used getDataFolder

#

i forgot to mention 🙄

orchid pasture
#

anyone know who the dev is for grief defender is

#

i need to get the sponge version of it from him

drowsy helm
#

message them on forums

orchid pasture
#

?

#

forums?

drowsy helm
#

on the spigot website you can message the dev

orchid pasture
#

how and where?

#

and whos the dev

orchid pasture
#

ye i did

drowsy helm
#

Hi, the sponge version is available on discord. You should of received a discord invite via paypal. Check spam/junk folder if you do not see it. If it expired, send an email to kanesoftware@outlook.com and I'll send a new one.

#

someone asked exactly the same question on his profile

viscid cave
drowsy helm
# viscid cave

file is relative to the working environment. you need a static path

viscid cave
drowsy helm
#

well yes its static just not in the right spot. you want to get the absolute path. its relative to the systems root, not the jar's dir

#

theres a method to get working dir, cant remember it though

viscid cave
#

oh, ok

tired bloom
#

hello i have a question

i want to make it so that when a player runs a command, it spawns an ArmourStand, adds the player as a passenger and slowly moves from point a to point b at an even rate with vectors

ive figured out everything apart from the vectors

any help appreciated

#

im new so if this is obvious then f

dark osprey
#

why use static?

drowsy helm
#

Huh

solid cargo
#

too lazy to rewrite

#

here, a bigger image of the code

royal jungle
#

help me

#

i have a problem

chrome beacon
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!

chrome beacon
#

^ something added the prefix to the display name

solid cargo
#

so whats the alternate method?

chrome beacon
#

getName

solid cargo
#

huh?

#

thats kinda weird. i was tought that getName is CraftBukkit name

#

bunch of gibberish

#

alright

verbal nymph
#

A user reported the following error by LibertyBans to me, telling them to tell me to relocate my dependencies.

Plugin 'SMPtweaks 1.0.13-beta' has shaded the library 'HikariCP' but did not relocate it. This may or may not pose problems. Contact the author of this plugin and tell them to relocate their dependencies. Unrelocated class detected was com.zaxxer.hikari.HikariConfig

Full error: https://www.spigotmc.org/threads/smptweaks.511138/page-2#post-4292496

From my googling, this means that two plugins are attempting to load the same class, causing a conflict, is that correct?
So I just gotta add a relocation like this?

<relocations>
    <relocation>
        <pattern>com.zaxxer.hikari</pattern>
        <shadedPattern>shaded.zaxxer.hikari</shadedPattern>
    </relocation>
</relocations>
chrome beacon
#

Relocate it to your plugin package

#

Otherwise yeah looks fine

eternal oxide
#

use the libraries entry in plugin.yml and you don't need to shade

visual tide
#

^^^ should use that if you're making it for an api-version that supports it

plush crescent
#

How do I determine that I have joined the server for the first time?

plain helm
#

player.hasEverJoined();

#

or hasEverPlayed

buoyant viper
#

oh thats much more elegant than what i was about to say

plain helm
#

lol

buoyant viper
#

was gonna say to check for existing playerdata files

plain helm
plain helm
#

wait non of those

buoyant viper
plain helm
#

@plush crescent p.hasPlayedBefore()

plush crescent
#

Thank you, that was very helpful. 🙏

plain helm
#

np

sharp saffron
#

is there a way to hide certain commands ie worldedit, so when a player does /<command> they wont see worldedit commands

plain helm
#

don't think so

buoyant viper
#

permissions?

plain helm
#

not gonna hide them

eternal oxide
#

worldedit does not obey permissions for commands.

buoyant viper
#

o? dam

rough jay
#

Hey I'd like to save HashMaps into a data file but what I tried doesn't seem to work...
Here are the code:

plush crescent
sullen marlin
#

No, world/playerdata entry for their uuid

plush crescent
#

I see. Thank you very much.

#

Sorry, it doesn't work: ...... Am I doing something wrong?
(I'd like to determine if this is your first time here.)

eternal oxide
#

!player.hasPlayedBefore()

#

if you only want to give to new players

plush crescent
#

It was a very rudimentary mistake: ..... I'm sorry, thank you very much.

rough jay
#

why is no one helping me 😭

elfin talon
#

how can i check how many players are in surrival mode?

eternal oxide
#

I'm pretty sure it doesn't

rough jay
#

saved data?

#

there is no saved data

eternal oxide
#

then why are you trying to load any? Look at your error stacktrace

rough jay
#

well when someone will install my plugin, they will start with no data

eternal oxide
#

has anyone taught you how to read a stacktrace?

rough jay
#

is there any way to set a default value? (to false for example?)

eternal oxide
#

depending on how you are getting the data, yes

#

First off, yoru save hash and loadHash methods will not work

rough jay
#

why?

iron palm
#

uh i had a maven project
but i accidently pressed the debug button and now i can't get build and i get a long gradle build error
what can i do?

eternal oxide
#

UUID is not serializable so bukkit will attempt to best guess its serialization as an object

#

and you can;t cast to a UUID, you have to use the static UUID methods to recreate it from a string

rough jay
#

oh

eternal oxide
#

so, getList is fine.

#

then you have to check its not null, then read each entry and create a UUID from it

#

probably somethign like UUID.fromString

eternal oxide
#

stop your debug

iron palm
eternal oxide
#

usually by pressing debug again, or (Eclipse will have a stop button in the debug log window)

iron palm
eternal oxide
#

I can;t help you with gradle nor InteliJ

rough jay
#

like this ElgarL?

public void loadHash() {
    List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
    if (suuids == null) return;
    for (String suuid : suuids) {
        UUID uuid = UUID.fromString(suuid);
        playerDataMap.put(uuid, playerDataMap.get(uuid));
    }
}
iron palm
eternal oxide
rough jay
#

also it tells me (suuids == null will always be false so isn't it better if I put (suuids.isEmpty()) instead?

ivory sleet
#

Did someone say gradle? 😄

eternal oxide
#

yes

#

^ gradle person

iron palm
eternal oxide
#

he clicked debug, now his gradle is fubar

ivory sleet
#

uh well just terminate the debug instance you started running?

tardy delta
#

isn't initializing fields to null redundant?

iron palm
ivory sleet
#

And looking from above, you should have a settings.gradle in your rootproject folder

ivory sleet
eternal oxide
ivory sleet
#

settings.gradle.kts and build.gradle.kts

tardy delta
#

ah

ivory sleet
#

.kts is optional

iron palm
ivory sleet
#

What error does it prompt

ivory sleet
#

As said

#

You need to have a settings.gradle in your root directory

#

Look at the link I sent

#

It’s a disaster to switch from gradle to maven but you’d have to delete all gradle related files, add a pom xml and restart and invalidate caches

iron palm
ivory sleet
#

everything containing gradle in it

#

But you’re not listening

#

There’s a much easier solution

#

Create a file called settings.gradle

#

Inside your project folder

iron palm
ivory sleet
#

literally is

#

build.gradle

#

Send a screenshot of your project tree

iron palm
glossy venture
#

the /gradle directory, /.gradle directory, /settings.gradle and /build.gradle

#

delete those

ivory sleet
#

And gradlew.bat, gradle.properties in case they’re present

glossy venture
#

gradle.properties is in /gradle

#

i think

ivory sleet
#

That’s a different one

glossy venture
#

oh

iron palm
#

why i cant send an image

glossy venture
#

use imgur

iron palm
#

ok

eternal oxide
#

or verify

glossy venture
#

wait can verified people send images

#

oh what

#

lmao

iron palm
#

oh i prefer verifying probably

eternal oxide
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

iron palm
#

phew

ivory sleet
#

Oh okay

#

Just File -> Settings > Invalidate Caches -> Invalidate Caches and Restart or something

#

Then when it opens up again, import it as maven project

rough jay
#

ElgarL is this method good now?

public void saveHash() {
    List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
    if (suuids.isEmpty()) return;
    Set<UUID> uuidSet = playerDataMap.keySet();
    for(UUID uuid : uuidSet) {
        suuids.add(String.valueOf(uuid));
    }
    plugin.getConfig().set("playerDataMap", suuids);
    plugin.saveConfig();
}
eternal oxide
#

no

#

um

iron palm
eternal oxide
#

playerDataMap?

rough jay
#

that's my string list

eternal oxide
#

oh thats saving

rough jay
#
public void saveHash() {
        List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
        if (suuids.isEmpty()) return;
        Set<UUID> uuidSet = playerDataMap.keySet();
        for(UUID uuid : uuidSet) {
            suuids.add(String.valueOf(uuid));
        }
        plugin.getConfig().set("playerDataMap", suuids);
        plugin.saveConfig();
    }

    public void loadHash() {
        List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
        if (suuids.isEmpty()) return;
        for (String suuid : suuids) {
            UUID uuid = UUID.fromString(suuid);
            playerDataMap.put(uuid, playerDataMap.get(uuid));
        }
    }
#

I'm also using it for loading

eternal oxide
#

why are you getting from config before saving?

#

delete first two lines in save

iron palm
eternal oxide
#

create a List, then add each UUID.toString()

rough jay
#

if I delete 2 first lines then what is suuids?

eternal oxide
#

make a List<String>

iron palm
#

ohhhh wasnt working

#

2:43:17 PM: Executing task ' --stacktrace'...

Starting Gradle Daemon...

rough jay
#

Variable 'suuids' might not have been initialized

eternal oxide
#

initialize it 🙂

#

new ArrayList<>();

rough jay
#
public void saveHash() {
    List<String> suuids = new ArrayList<>();
    Set<UUID> uuidSet = playerDataMap.keySet();
    for(UUID uuid : uuidSet) {
        suuids.add(uuid.toString());
    }
    plugin.getConfig().set("playerDataMap", suuids);
    plugin.saveConfig();
}
eternal oxide
#

yep

rough jay
#

good now?

#

great

alpine urchin
#

save hash can be misleading

rough jay
#

ok

#

bruh I'm still having issues

opal juniper
#

what issue

eternal oxide
#

yes, your error was nothing to do with your save/load

rough jay
#

Cannot invoke "net.reikeb.maxicity.datas.PlayerData.setPlayerTeam(String)" because the return value of "java.util.HashMap.get(Object)" is null

eternal oxide
#

WHich was when I asked you if anyone had taught you have to read a stacktrace

#

the next line tells you where the error is from

rough jay
#

yeah well I always have playerDataMap.get(p.getUniqueId())

#

that's the issue

opal juniper
#

get or default it

#

or null check

tardy delta
#

does Integer.parseInt of a coloured string works?

rough jay
#

I never add the player's ID to playerDataMap

eternal oxide
#

yep, there is no entry in the map for that player

opal juniper
eternal oxide
tardy delta
#

oh

rough jay
opal juniper
#

well what is the hashmap

#

i’m assuming you have a player data class

rough jay
#

playerDataMap.put(p.getUniqueId(), new PlayerData());

opal juniper
#

or is it the actual bukkit one

rough jay
#

is good?

opal juniper
#

uh just do getOrDefault(key, new PlayerData())

rough jay
#

I'm adding player's UUID to playerDataMap because it was never added

lean gull
#

does anyone know how i can make an animation with particles that looks like there are dots following the shape of a square? so like 4 dots in an outline of a square and each dot is like facing a different way, and then they all go forward until they hit a corner and then they turn by 90 degrees and repeat

lean gull
#

oh and also without any entities or blocks or anything, just pure math

paper viper
#

to its side

#

with some rounded edges

lean gull
#

huh?

#

i just put a rail track on a square and then added particles like 3 blocks above the minecarts to make an example

summer scroll
#

can u upload the video to imgur? for some reason streamable is blocked on my country

proven whale
#

how can I make the time of each world different?I have no idea about it.

maiden mountain
#

How can I change the font size of a message?

lean gull
#

resource packs

#

there are also symbols that resize your message by a tiny bit but also make ur message look a bit weird/cool

maiden mountain
#

Is there a page with all the symbols?

lean gull
#

wdym

proven whale
#

May I ask how to let different worlds have different times

maiden mountain
#

Well, you mentioned that there are symbols that resize my message

lean gull
#

well only by a tiny bit

maiden mountain
#

hmmm

#

Then how those those plugins send message where the text is big?

#

For example

young knoll
#

That’s just ChatColor.BOLD

lean gull
#

ohh you mean bold

maiden mountain
#

hmm

#

so there is no way to change the actual font size per message?

lean gull
#

i don't think so, sorry

maiden mountain
#

No worries ahaha

lean gull
maiden mountain
#

Ah so bold it is

#

Thanks

lean gull
#

i was talking about the weird little lines in A and O but ok, have fun

proven whale
#

May I ask how to let different worlds have different times

quaint mantle
#

in-game time or real-time or what?

#

that really depends

#

you didnt tell us all the information...

proven whale
#

emm

#

in-game

#

maybe

young knoll
#

Isn’t time already per world

quaint mantle
#

then just set the time in game by using /time set for every world 😂

#

set them different

proven whale
#

?

#

But

quaint mantle
proven whale
#

Other worlds will change into the same one as I use /time set

quaint mantle
#

idk bout that

#

so im just gonna disappear

proven whale
#

I will think it over ,thanks

lean gull
#

can anyone help me with my thing please?

lean gull
rough jay
#

I have an issue

#

It seems to forget things lol

#

My Minecraft has Alzheimer

#

Nothing is written in config.yml

proven whale
#

I would like to ask if there is a kind of item which can have no ItemMeta

young knoll
#

Air

summer scroll
coral helm
#

Issue with getting world from yml file.

formal ferry
#

issue with redis connection

hardy agate
#

Basic syntax problem?? I think??

summer scroll
glad iron
summer scroll
#

what version should i use?

dark osprey
#

3.4.5

summer scroll
#

what is the reason that i need to change the version?

dark osprey
summer scroll
#

ah well, i still got the error.

dark osprey
#

I also have problems with my plugin.

#

I need the full code.

summer scroll
dark osprey
#

I'm not sure. Depends on the code.

summer scroll
#

Is my configuration for the sqlite database correct?

quaint mantle
#

Someone correct me if I'm wrong but pretty sure SQLite doesnt need to be used with hikaricp

hardy agate
#

How to create a new key in YAML?

quaint mantle
#

It's more for remote connections

summer scroll
#

Yeah you're correct, Hikari doesn't designed for SQLite I guess.

#

Since I use Hikari for the MySQL part, so why not use it for the SQLite too, but if it doesn't work then I'm gonna use the java jdbc.

quaint mantle
#

It's not that it's not compatible, just that SQLite connections can be created much faster since it's local

dark osprey
#

like this code ``` hikari.setJdbcUrl("jdbc:mysql://" + this.credentials.getHost() + ":" + this.credentials.getPort() + "/" + this.credentials.getDatabaseName() + "?autoReconnect=true");

summer scroll
#

that's the mysql

#

i dont have problem with mysql

solid cargo
#

why doesnt Action.RIGHT_CLICK_AIR work?

quaint mantle
summer scroll
#

Alright thanks, but I have one question.

#

So before I'm using Hikari, I store the connection on a field everytime I'm opening a connection, and let the connection closes itself, and if the connection is still there i'll reuse it, is that the right thing to implement it with SQLite? Because you can only open one connection otherwise you'll get a SQLITE_BUSY error.

solid cargo
#

this is my code:

do cool stuff
}
quaint mantle
#

You can reuse connections for SQLite yes

solid cargo
#

i have it

quaint mantle
#

kk

solid cargo
#

update: it needed if instead of else if

quaint mantle
#

isnt it better to use == instead of .equals

#

?

rough jay
#

plz help

quaint mantle
rough jay
#

yes

#

check the code

unique meteor
proven whale
lavish hemlock
#

Alright

#

Time for Maow to reiterate the difference between reference and value comparisons.

#

== - reference comparison, this compares if the reference to an object is the same, AKA it's the same instance of a class.
equals - implemented per class, this compares if the values of the object are the same, AKA it contains the same data.

#

(reference comparisons are also known as identity comparisons)

#

The equals of an Enum will just check via identity comparison anyways, but it's better to use identity comparison since it's one less method call and it's cleaner to read an infix operator as opposed to a method call.

#

Enum constants will always be the same reference across the lifespan of the program, as they are static.

#

so pretty much there's not much of a difference

#

it's enum.equals(otherEnum) vs enum == otherEnum in terms of codestyle

quaint mantle
#

Instance a == instance b if and only if instance a is instance b

lavish hemlock
#

ye

#

that's why you should use equals on Strings btw!

#

not doing so can lead to some strange errors

#

sometimes == may or may not work due to interning

quaint mantle
#

Yuh value based class there

lavish hemlock
#

(also don't intern Strings via intern, use Guava's Interner, intern is very slow)

tardy delta
#

Uhh how i loop through a map and get take the biggest value and return the key and the value?

#

I dunno how you get the key

lavish hemlock
#

that includes info on String.intern btw ^

#

uhhh

#

could you rephrase that so it's easier to understand? @tardy delta

tardy delta
#

😔

lavish hemlock
#

so

#

you want to return the key of the entry after you've found the max value?

tardy delta
#

Yez

lavish hemlock
#

you'd probably have to store the key alongside max and then return it at the end of the method

#

so, basically

String key;
// ... loop - set key here ...
return key;
#

actually

#

better idea

#

you could just store the entry itself

#

since that would include the key and value anyways

#

making that one less assignment and one less local variable

tardy delta
#

Hmm yea

lavish hemlock
#

(and technically one less method call since you no longer have to call getKey on the entry to store the key)

#

then at the end of the method you can return entry.getKey()

tardy delta
#

Lieke this?

lavish hemlock
#

ye

tardy delta
#

But how do i give it a value without let that run every time so the max is gone?

flint badger
#

So I'm working with a custom shapedrecipe rn how can I make one of the ingredients a poison potion

lavish hemlock
#

this is a question that has been asked for many years

#

damn

quasi patrol
#

So if I have a list string, how can I combine into a regular string and have it say "Hello" instead of like "{"h","e","l","l","o"}"?

quaint mantle
#

String.join("", iterable)

lavish hemlock
#

mmm yes one of the best fuckin' methods

quasi patrol
quaint mantle
#

you're on java 8?

#
String join(String delim, List<String> list) {
    StringBuilder builder = new StringBuilder();
    ListIterator<String> it = list.listIterator();

    while (it.hasNext()) {
        builder.append(it.next());
        if (it.hasNext()) {
            builder.append(delim);
        }
    }
    return builder.toString();
}

// No delim

String join(List<String> list) {
    StringBuilder b = new StringBuilder();

    for (String i : list) {
        b.append(i);
    }
    return b.toString();
}
lavish hemlock
#

I don't think you really need a ListIterator there

quaint mantle
#

it can be a normal iterator

lavish hemlock
#

or you could just not use an iterator

quaint mantle
lavish hemlock
#

yeah

#

so?

quaint mantle
#

i would just use a iterator

#

there's no difference

lavish hemlock
#

it's literally just if (i != size - 1)

quaint mantle
#

I know

#

there's no issue with this version

#

iterator looks fancier

quaint mantle
lavish hemlock
#

there's a small difference in performance bc of method call overhead and the object instantiation required for an iterator

quaint mantle
#

🤦🏿‍♂️

lavish hemlock
#

and it's not even like you're going to be typing this over and over since it's a util method, so just like, use a for loop

quaint mantle
#

iterator is universal, for can be used only on lists

lavish hemlock
#

that is backwards

#

I'm not referring to a for-each loop

#

and, for-each loops internally use an iterator

#

iterators are only available for objects that implement Iterable

quaint mantle
#

maow

lavish hemlock
#

meanwhile for is just a basic loop statement

quaint mantle
#

ok

#

maow

lavish hemlock
#

that has an init, condition, and step

quaint mantle
#

you realize people get mad about you rambling on about the most minimal stuff

#

i prefer to ignore it

#

honestly this looks like that you wanna show your java knowledge if if noone asked

patent horizon
#

is there a way to set the name of a gui after creating it?

lavish hemlock
#

it's just useless to use an iterator for no reason :p

quaint mantle
#

you could've just said: i would use the size solution for performance and the universitality of it

tardy delta
#

Make a new gui and set the contents

quaint mantle
#

i wish there was an Inventory#setTitle method

#

then updateInventory would actually have a use

patent horizon
tardy delta
#

Uhh

#

Never deleted?

patent horizon
#

yeah

#

last time i put the create gui thing inside my function, the events would end up stacking every time i created a new gui

lavish hemlock
#

if I just said "for performance," then it would be unclear why it's more performant

#

I like to go in-depth bc it actually TEACHES people shit

tardy delta
#

It's just inventory inv = bukkit createinv bla bla bla and then inv = bukkit createinv with the new name

lavish hemlock
#

instead of just saying "oh ye this is slower, have a good day"

patent horizon
#

Inventory GUI = Bukkit.createInventory(null, 27, "Guilds"); yeah whenever i put this in the function, it stacks

quaint mantle
#

gui

lavish hemlock
tardy delta
#

Theres also one without the holder iirc

lavish hemlock
#

I'm not even trying to be an asshole :p

tardy delta
#

So with 2 paramameters

#

Smh paramameters

patent horizon
#

whats the holder?

#

gui owner?

#

where the null goes

tardy delta
#

InventoryHolder

#

Yes

patent horizon
#

ah ok

lavish hemlock
tardy delta
#

I might also be without the name 😔

raw coral
#

Im trying to make a custom reconnect handler.

package xyz.fragbots.handlers

import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.ReconnectHandler
import net.md_5.bungee.api.chat.ComponentBuilder
import net.md_5.bungee.api.config.ServerInfo
import net.md_5.bungee.api.connection.ProxiedPlayer
import net.md_5.bungee.api.event.PlayerDisconnectEvent
import net.md_5.bungee.api.event.PreLoginEvent
import net.md_5.bungee.api.plugin.Listener
import net.md_5.bungee.event.EventHandler
import xyz.fragbots.SandboxServerManager
import xyz.fragbots.player.ProxiedPlayerExtensions.isStaff
import xyz.fragbots.utils.ChatHelper
import xyz.fragbots.utils.Config
import java.util.*
import kotlin.collections.HashMap

class SandboxReconnectHandler(val main:SandboxServerManager) : ReconnectHandler, Listener {
    val onlinePlayers = HashMap<UUID,ServerInfo>()
    init {
        ProxyServer.getInstance().reconnectHandler = this
    }
    override fun getServer(player: ProxiedPlayer): ServerInfo? {
        if(!player.isStaff()&&Config.maintanence){
            player.disconnect(ComponentBuilder(ChatHelper.format("&cServer is in maintanence mode!")).currentComponent)
            return null
        }
        val server = main.serverHandler.getHub()
        if(server==null){
            player.disconnect(ComponentBuilder(ChatHelper.format("&cNo hubs online!")).currentComponent)
            return null
        }
        onlinePlayers[player.uniqueId] = server
        println("Player ${player.displayName} is being sent to hub: ${server.name}")
        return server
    }

    override fun setServer(p0: ProxiedPlayer?) {
    }

    override fun save() {
    }

    override fun close() {
    }

    @EventHandler
    fun onDisconnect(event: PlayerDisconnectEvent) {
        onlinePlayers.remove(event.player.uniqueId)
    }
}

But for some reason when a player gets disconnected in the get server it still shows their join and leave messages

lavish hemlock
#

prepare to get no support since nobody in here knows how to code in Kotlin

#

anyway you'd probably have to remove the messages yourself?

#

I've seen plugins that do that somehow

raw coral
#

I mean it's more of knowing how bungeecords api works, and I'm wondering why the message is sending even though the player is never being sent to the server

lavish hemlock
#

welp I cannot help then

#

I am not experienced in Bungaycord Bungeecord

raw coral
#

Well are there any better proxy services.

tardy delta
#

Woah kotlin

lavish hemlock
#

Kotlin is cool 👌

#

incoming Java tryhards

raw coral
#

How can i remove the join messages

quaint mantle
raw coral
#

Alright thanks 👍

tidal hollow
#

Does anyone know how to connect minecraft to a discord bot?

lavish hemlock
#

Are you supposed to shade Adventure?

chrome beacon
#

If you want spigot support I think you need to do that

#

Paper has adventure included

lavish hemlock
#

aight

#

it's just that it's a big library so I was wondering

#

like it adds 600kb to the output jar when shaded (api + platform) lmao

chrome beacon
#

Yeah maybe just target Paper

lavish hemlock
#

no lol

valid solstice
#
[01:21:37 WARN]: **** FAILED TO BIND TO PORT!
[01:21:37 WARN]: The exception was: java.net.BindException: Address already in use
[01:21:37 WARN]: Perhaps a server is already running on that port?
``` anyone know why is this happening?
chrome beacon
#

Or you could use the library loader feature

lavish hemlock
#

that makes it harder to ensure Spigot compat

valid solstice
#

there was something weird happening with my server, then i just delete the session.lock file in my world

lavish hemlock
valid solstice
#

how would i shut that down?

lavish hemlock
#

Task Manager

chrome beacon
#

Or just restart pc if you don't know how

lavish hemlock
#

(also I'm trying to support 1.14+, library loader is only available for 1.16-1.17 I believe)

chrome beacon
#

Yeah shading is the only option then

#

You could use ProGuard with Gradle so minimize the jar as much as possible

lavish hemlock
#

any guide for that?

#

their docs are pretty bad afaik

valid solstice
#

it worked

chrome beacon
#

Yeah

valid solstice
#

thanks

#

but

``` this popped up...
#

should i just ignore it?

lavish hemlock
#

probs

chrome beacon
#

Not sure if there are any good docs. I did get things running a couple of years ago worked very well

#

Idk if I still have the project

tacit mica
#

I assume I just messed up a configuration in my IntelliJ setup, can anyone help? Can't seem to access the NKMS packages, though they're in the files and not visibly causing errors
When I try to build, stuff such as this comes up: cannot access net.minecraft.core.Vector3f
Here's the dependency part of my pom

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.17.1-R0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.17.1-R0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
#

Nevermind, was compiling with JDK 14 instead of 16, the errors seem to have gone away for now

valid solstice
#

anyone know why this is crashing my server with "timed out"? My goal is to spawn a circle-shaped particle effect around the player every 20 ticks if isEnabled is true

while(isEnabled==true){
            Location location = player.getLocation();
            double x = (radius * Math.sin(angle));
            double z = (radius * Math.cos(angle));
            angle += 0.1;
            new BukkitRunnable() {
                @Override
                public void run() {
                    location.getWorld().spawnParticle(Particle.REDSTONE, location.getX()+x, location.getY(), location.getZ()+z, 0, 0, 1, 0);
                }
            }.runTaskLater(mainClass, 20); //FIXME
        }
spare marsh
#

Infinite loop

valid solstice
#

true will be set to false eventually

hollow aspen
spare marsh
#

While true it will be creating new Rummanles

#

Runnable

spare marsh
#

Why don’t you instead create a Runnable that will cancel@itself until a condition is met instead of starting a new Runnable a lot of times while true

valid solstice
spare marsh
#

Aren’t you scheduling a task to run later every time The while loop runs?

valid solstice
hollow aspen
#

you should be able to schedule it to repeat

#

here's an example

      Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin plugin, new BukkitRunnable() {
            int i = 0;
            public void run() {
                i++;
                    p.sendMessage("REPEAT MESSAGE");
                    if(i == 5) {
                        this.cancel();
                    }
                }
            }, 60L, 20L);
valid solstice
#

whats params are 60L 20L?

spare marsh
#

That would be better

#

It stands for Long in Java

hollow aspen
#

lemme look it up i forget

spare marsh
#

60 is seconds in a minute and 20 is the amount of ticks in a second J believe, I’m not too sure

#

L is for Long

hollow aspen
#

60L is delay (in ticks) for when the first loop starts, and then 20L is how often it repeats (again in ticks)

valid solstice
#

ah i see

#

i get it now

tacit mica
#

From quickly looking online, is there any way to change a hopper's speed and amount of items, through code, and not via configurations? I'm wanting them to have specific speeds based on worlds

#

The only thing I can think of is making a whole event handler for it

#

Could it be something under hopper.getBlockData(), if it has a built in method?

hollow aspen
# valid solstice i get it now

just for further clarification, here's this

Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin plugin, new BukkitRunnable() {
    public void run() {
        //do whatever
        if(!isEnabled) {
            this.cancel();
        }
    }
}, delay, repeatTimer); //Delay when starting first task, how oten it should repeat
spare marsh
hollow aspen