#help-archived

1 messages · Page 170 of 1

tiny pebble
#

it seems to need single quotes

stoic shell
#

oh

subtle blade
#

Yeah I'd bet you that a . is a special character, Tanku

stoic shell
#

so then how would I get a dyecolor from a color, if there's no mapping?

subtle blade
#

You don't. Where did that byte colour come from?

tiny pebble
#

When I made the command add quotes, it wrapped itself in single quotes

but I can't add single quotes as it will then wrap it in double single quotes

and when I don't add single quotes it is just a normal string without single quotes

#

Also I've tried it with the permission minecraft, same thing

stoic shell
#
public class TeamColor {
   String prefixColor;
   String teamName;
   Color color;
   int colorID;

   public TeamColor(String prefixColor, String teamName, Color color, int colorID) {
      this.prefixColor = prefixColor;
      this.teamName = teamName;
      this.color = color;
      this.colorID = colorID;
   }

   public Color getColor() {
      return this.color;
   }

   public String getChatColor() {
      return this.prefixColor;
   }

   public byte getByteColor() {
      return (byte)this.colorID;
   }

   public int getIntColor() {
      return this.colorID;
   }

   public String getTeamName() {
      return this.teamName;
   }
}
#

I have a colorID if that's useful

tiny pebble
#

So now the main question is:
If it needs single quotes why in the world won't it let me add them

subtle blade
#

int colorID

#

Replace that int with a DyeColor 🙂

#

Whenever you construct a TeamColor, pass instead a DyeColor rather than an integer

#

(the getIntColor() can be deleted too as it serves the same purpose as getByteColor())

stoic shell
#

wait a moment

#

I can get a DyeColor from a Color...?

subtle blade
#

I had remembered a method similar to that but wasn't sure if it still existed. Yeah, you could. Though it might be better to just pass a DyeColor through the constructor anyways

#

That method has to do a bit of math to get a good estimate of what DyeColor best represents it

tiny pebble
#

The problem I'm having lies within this:

List<String> list = usersConfig.getStringList(uuid + ".permissions");
list.add(name);

I don't know what is happening man it reads it as an empty list although the list ain't empty and the path is correct

#

Should I read it as something else?

stoic shell
#
   public DyeColor getDyeColor() {
      return DyeColor.getByColor(this.color);
   }```
subtle blade
#

Orrrr, again, just pass one in through the constructor lol

stoic shell
#

does this look like that should work?

subtle blade
#

Or at least get that DyeColor from the constructor. Whatever

stoic shell
#

well I could, but I think that might have a lot of usages to change

wet bronze
#

you shouldn't be doing debugging on a live servers anyway
@tiny dagger I tried it, and movecraft works fine on the separate server.

subtle blade
#

Well that int parameter from the constructor is gonna have to get removed anyways

#

As it won't be used

edgy socket
#

Hello people, Earlier today i asked a few questions but couldnt continue sadly (Thanks to 7smile7 and arcaniax for trying to help me!), We couldnt figure out how we broke TNT duping but now we want to rewind to vanilla from spigot until we find a long term solution. Sadly when we tried our nether dimension (and potentially the end dimension) reset, any idea's how we can rewind to vanilla without reseting them?

stoic shell
#

oh

#

it has only one other usage

#
      ConfigurationSection section = conf.getConfigurationSection("Teams");
      if (section != null) {
         for(int i = 0; i < section.getKeys(false).size(); ++i) {
            String start = "Teams.Team" + (i + 1);
            String prefixColor = conf.getString(start + ".ColorPrefx").replaceAll("&", "§");
            String teamName = conf.getString(start + ".ColorName");
            Color color = Color.fromRGB(conf.getInt(start + ".Color.r"), conf.getInt(start + ".Color.g"), conf.getInt(start + ".Color.b"));
            int colorID = conf.getInt(start + ".BlockColorID");
            TeamColor teamColor = new TeamColor(prefixColor, teamName, color, colorID);
            teamColors.add(teamColor);
         }
      }```
edgy socket
#

Should i post my problem anywhere else to not clog up this chat?

stoic shell
#

trivial to change?

#

For your first question, I don't think so net...

edgy socket
#

Alright, hopefully someone can spot it

#

ill try rewriting it later

stoic shell
#

hmm

edgy socket
#

quick question, would it even be possible to degrade from spigot to vanilla without reseting the nether and the end?

stoic shell
#

oh wait

#

tnt duping

sturdy oar
#

why would you use vanilla server?

stoic shell
#

that's in paper.yml

edgy socket
#

well we broke tnt duping...

stoic shell
#

you can re-enable it

#

if you have paper

edgy socket
#

um

#

sorry but

sturdy oar
#

this is not Paper discord, go there if you're using that

edgy socket
#

idk whats paper

#

,im not very experienced with this stuff

stoic shell
#

well then I don't think you can change it

latent coyote
#

Did anybody ever use this?

JavaPlugin.getPlugin(Main.class)
sturdy oar
#

not really

#

it's slow

#

I think it uses reflection

latent coyote
#

i always used dependency injection

sturdy oar
#

yeah keep using it, nothing wrong with it

latent coyote
#

it gets hard to track after some time

stoic shell
#

There 😄

#

I changed the constructor and it's usages

#

Now I have a getDyeColor()...

lapis plinth
#

Confused on why this isnt working

mellow wave
#

Entity != EntityType

edgy socket
#

Hey snoopy, if ur not busy rn could i ask you a few quick questions on DM?

stoic shell
#

being?

edgy socket
#

I am kind of confused by what you meant when you said "If you have paper"

mellow wave
#

Paper is a fork of Spigot

edgy socket
#

Is there a way i can know ingame if a server is Paper?

stoic shell
#

wut...

mellow wave
#

It will say when you run /version

stoic shell
#

I thought you're running the server...?

mellow wave
#

This isn't exactly the paper discord

edgy socket
#

Oh, sorry

#

also i did use the /version now, yes we are on paper

#

ill go find the paper discord

#

Thank you for your time!

lapis plinth
#

@mellow wave how would I do it then?

mellow wave
#

Not too hard, event.getRightClicked().getType() == EntityType.VILLAGER

stoic shell
#

huh

#

well...

#

What do I do with the DyeColor now to get a terracotta material with the color?

#

I think Choco said Map<DyeColor, Material>, but how do I use that?

stiff thistle
#

I want to create a plugin that will display the title to the player when I log in.
Please let me know if you know.

grim halo
#

I know.

wheat mirage
#

@scenic hound Learn java

#

@scenic hound It's more than anyone can answer in a discord message

#

Use an online tutorial or the oracle docs

#

A fundamental knowledge of java will help you make good, efficient, quality plugins.

#

Not exactly being rude

#

That's the truth

#

It would be rude if I said "Use an online tutorial, asshole"

grim halo
#

You dont need to be explicit in order to be rude. And the Answer you gave was not exactly polite.

#

@scenic hound You basically need an instance of your object you want to reach in an acessible scope.
Thats the answer.

#

But you might look into java

desert kraken
#

theyve all frozen in place

#

they wont eat, or move or anything, i assume theyre inactive but how do i fix it

mellow wave
#

Do you have any plugins that freeze mobs under heavy load

desert kraken
#

would ETF count?

#

entitytrackerfixer

stoic shell
#

I still dunno how to get a Material from a block name and a DyeColor...

grim halo
#

@desert kraken is your TPS ok?

desert kraken
#

yeah, been at 20 for past 12 hours or so

mellow wave
#

Yeah I belive that might be the cause but it's not supposed to do it when the player is close

desert kraken
#

tick duration isnt long either

grim halo
#

Material from a name would be
Material.valueOf(name)

desert kraken
#

incoming plugin spam

stoic shell
#

huh?

grim halo
#

@stoic shell What exactly do you need?

edgy socket
#

i found the paper discord server, thanks everyone!

stoic shell
#

I have a DyeColor, and I need a terracotta Material of the color.

grim halo
#

Material.valueOf(dye.toString().replace("_DYE", "_GLAZED_TERRACOTTA"))

#

Or use a Map<Material, Material> pref EnumMap

stoic shell
#

How would I do the second?

#

seems cleaner

grim halo
#
  1. Create a new EnumMap<Materia, Material>(Material.class)
  2. Fill it with key->dye value->terracotta
stoic shell
#

nvm...

#

oh wait

#

I found this: block.setType(Material.getMaterial(dyeColor.name() + "_TERRACOTTA"));

#

would this work fine?

#

And second, my IDE says this, is this an actual concern?

grim halo
#

Yes its a valid concern. No, it wont work.

#

Wai´t

#

Hm it might work.

#

Why not just create a static Map ? Its way faster than using some String stuff.

keen compass
#

it is possible that the block you are getting from the location can be air @stoic shell

#

which is equivalent to being null

stoic shell
#

huh?

#

oh

grim halo
#

Thats not what the warning is about

stoic shell
#

but the author didn't have anything about that before I changed this to use a DyeColor

grim halo
#

Material.getMaterial might be null

stoic shell
#

well if it compiles, I'll leave it for now at this point 👀

#

but it doesn't compile... I'm getting complaints of... duplicate variables?

subtle blade
#
public static final Map<DyeColor, Material> COLOR_TO_TERRACOTTA = new ImmutableMap.Builder()
    .put(DyeColor.BLACK, Material.BLACK_TERRACOTTA)
    .put(DyeColor.RED, Material.RED_TERRACOTTA)
    // etc. - do this for all dye colours
    .build();

// somewhere else
Material redTerracotta = COLOR_TO_TERRACOTTA.get(DyeColor.RED);```
lone fog
#

I always used valueOf to get material from strings

#

Is that bad

subtle blade
#

Throws an exception if not present

stoic shell
#

well then I have to do that for all the dye colors...?

lone fog
#

Ah yeah I guess null is better than an exception

subtle blade
#

Yes, all the colours

#

Though it's the fastest way to map your colours to materials

stoic shell
#

eh alright, I'll get back to it after I get this done

lone fog
#

It's only 16

#

Not that bad

stoic shell
#

currently, there's bigger problems

#

it won't compile due to duplicate variables

grim halo
#
  private static final EnumMap<DyeColor, Material> DYE_TO_TERRACOTTA = new EnumMap<>(DyeColor.class);

  static {
    for (final DyeColor color : DyeColor.values()) {
      try {
        final Material terraMat = Material.valueOf(color.name() + "_TERRACOTTA");
        DYE_TO_TERRACOTTA.put(color, terraMat);
      } catch (final Exception ignored) {}
    }
  }
subtle blade
#

Please don't use string manip like that

#

Those dye colours aren't guaranteed to be 1:1

stoic shell
#

smile, is that basically a better version of what I was doing?

grim halo
#

Not sure.
If the format is always
<Color>_TERRACOTTA and matches the values of DyeColor then yes.

#

Otherwise you would need to manually fill the map

stoic shell
#

pretty sure it is

#

is this just basically faster?

grim halo
#

Yes. You just call DYE_TO_TERRACOTTA.get(color) and it returns the material or null if its not in the map

subtle blade
#

Still heavily advise against that method

#

Just write in the mapped values manually

#

It's more readable and you can easily pick out errors. Typo TERACOTTA and you're going to spend hours figuring out why it won't work. Or maybe TERRACOTTA will change in the future but you won't ever know because you have a String value

stoic shell
#

then maybe I just don't ignore the exception, instead print out something?

subtle blade
#

Or...

#

Just write in the mapped values manually

#

I'm not sure why you're all so insistent on not doing that

grim halo
#

Its not that many

keen compass
#

got to love it when people ignore the recommended ways

grim halo
#

You can also choose the ImmutableMap approach with a wrapped EnumMap

Maps.immutableEnumMap()
unborn jewel
#

how can I get a user rank with vault or without

grim halo
#

Of what plugin?

keen compass
#

vault is for permissions

#

you don't really need vault though

unborn jewel
#

The Rank plugin im using is LuckPerms

grim halo
#

I dont... understand that sentence

stoic shell
#

there

subtle blade
#

Ranks aren't wrapped by Vault

stoic shell
#

alright, moving on

subtle blade
#

Permissions, economy and chat are

unborn jewel
#

oh, they told me to use vault for some reason

#

to get their rank

stoic shell
#

so... now I have duplicate variable compile errors... that I did not make

subtle blade
#

To my knowledge, those aren't exposed by Vault. Though maybe I'm wrong

unborn jewel
#

Choco what part Canada you from?

subtle blade
#

Well you have issues like these which are easily resolvable:

incompatible types: int cannot be converted to DyeColor
                TeamColor teamColor = new TeamColor("&f", "Not setUp yet", Color.WHITE, 0);```
Change that 0 to DyeColor.WHITE
#

I'm in Southern Ontario

stoic shell
#

k, lemme fix those first

subtle blade
#

Are you working based on decompiled code?

#

It's fine if you are, just curious

stoic shell
#

yes

#

Is that the cause of the duplicate variables?

subtle blade
#

That's quite possible, though it also explains names like var15

unborn jewel
#

Cool, Im in north of Ontario

subtle blade
#

You'll end up with a lot of oddities because decompiled code obviously isn't 1:1 with source

stoic shell
#

right

#

oh cmon

#

my IDE froze again .-.

unborn jewel
#

so, should I be using their api to get the player's rank?

stoic shell
#

and it unfroze, now I can fix that...

keen compass
#

you can use vault to get ranks if ranks are based on permissions

stoic shell
#

alright I fixed that

unborn jewel
#

they are based on weight

keen compass
#

then obviously vault isn't going to work for that 😛

unborn jewel
#

😢

#

so, I guess im going to their api

stoic shell
#

oh no

unborn jewel
#

froze again?...

stoic shell
unborn jewel
#

did ya make a method for it?

stoic shell
#

remember when I replaced int with dye?

unborn jewel
#

yea

stoic shell
unborn jewel
#

ah

stoic shell
#

well now I need an int, cause it was used somewhere else

#

the complete line in question is:

ItemStack it = GeneralMethods.CreateItem(ChatColor.DARK_PURPLE.toString() + (i + 1) + ". team", GeneralMethods.arrayToList(new String[]{teamColor.getChatColor() + teamColor.getTeamName()}), Material.TERRACOTTA, teamColor.getDyeColor());
#

but it needs an int apparently...

#

oh look at that

#

CreateItem in GeneralMethods uses a deprecated method

#

How can we modernize this?

#
   public static ItemStack CreateItem(String name, List<String> loreList, Material material, int data) {
      ItemStack item = new ItemStack(material, 1, (byte)data);
      ItemMeta meta = item.getItemMeta();
      if (!name.equalsIgnoreCase("")) {
         meta.setDisplayName(name);
         meta.setLore(loreList);
      } else {
         meta.setDisplayName(ChatColor.BOLD + " ");
      }

      meta.addItemFlags(new ItemFlag[]{ItemFlag.HIDE_ATTRIBUTES});
      meta.addItemFlags(new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS});
      item.setItemMeta(meta);
      return item;
   }```
#

ItemStack Deprecated, and uses data

subtle blade
#

Can just remove the data from that all together

#

Pass in the Material instead

#

Well, rather, you already have a Material lol

stoic shell
#

huh...

subtle blade
#

The data argument. There is no data in 1.13. They're all separate materials

stoic shell
#

oh yeah

subtle blade
#

So instead of passing Material.TERRACOTTA, you'd pass the material you fetch from the Map like you did last time

stoic shell
#

then it conflicts with the below method

#

which is:

#
   public static ItemStack CreateItem(String name, List<String> loreList, String url) {
      ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
      if (url.isEmpty()) {
         return head;
      } else {
         SkullMeta headMeta = (SkullMeta)head.getItemMeta();
         GameProfile profile = new GameProfile(UUID.randomUUID(), (String)null);
         profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString("{textures:{SKIN:{url:\"" + url + "\"}}}")));

         try {
            Field profileField = headMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(headMeta, profile);
         } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException var8) {
            var8.printStackTrace();
         }

         if (!name.equalsIgnoreCase("")) {
            headMeta.setDisplayName(name);
            headMeta.setLore(loreList);
         } else {
            headMeta.setDisplayName(ChatColor.BOLD + " ");
         }

         headMeta.addItemFlags(new ItemFlag[]{ItemFlag.HIDE_ATTRIBUTES});
         headMeta.addItemFlags(new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS});
         head.setItemMeta(headMeta);
         return head;
      }
   }```
subtle blade
#

That doesn't conflict though. String vs Material

#

Signatures are different

stoic shell
#

oh

#

nvm

#

that's the method above it lol

#

so I can just get rid of that method altogether, since the method above is the same without data

subtle blade
#

Yep

stoic shell
#

and then another 2 above that are the same scenario, I removed one

#

oh

#

What color is data 8 on stained glass pane...

#

light grey I found

#

fixing issues of the same nature...

unborn jewel
#

ok so I think its actually based permissions

subtle blade
#

This is why we were happy with 1.13 lol

unborn jewel
#

because im look at lp doc and this is one of their examples

#
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
    for (String group : possibleGroups) {
        if (player.hasPermission("group." + group)) {
            return group;
        }
    }
    return null;
}
stoic shell
#

xD

#

there's a bunch more the same way, still fixing

past star
#

Is this the channel for problems I have?

unborn jewel
#

yes

keen compass
#

Oh most definitely but not for any problems though

#

?ask

worldly heathBOT
#

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.

stoic shell
#

oh dang

past star
#

ok well I have a spigot server and I wanted to allow my friends to join it, so I followed the instructions on the wiki

stoic shell
#

I fixed the ones I saw, tried to build again (expecting build failed) and I got build failed of course.

past star
#

But the thing it tells you to download requires Java 9, which you cant download

#

So is there another way?

unborn jewel
#

eh

past star
#

I already tried just port forwarding

unborn jewel
#

you got java 9?

past star
#

No

#

You cant download it

unborn jewel
#

then download java 8

past star
#

It doesnt work with it

unborn jewel
#

yea it does

keen compass
#

could even use Java 14

unborn jewel
past star
#

Yeah show me where Java 9 is in here

#

I can use 14?

keen compass
#

yes

past star
#

Oh ok

unborn jewel
#

how does this work ```java
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}

stoic shell
#

oh neat

#

I found that DYE_TO_TERRACOTTA very useful 🙂

#

I put it in it's own util class since I realized that's gonna be needed again later, and it was

#

also, I've got while loop replaceable with enchanced for ALOT

sturdy oar
#

Yes

#

While loop dumb

stoic shell
#

and raw use of parameterized class Iterator

#

alot

sturdy oar
#

Just correct them?

stoic shell
#

I bet it's due to decompilation.

sturdy oar
#

What have you decompiled

stoic shell
#

for some reason they always prefer to use Iterator 🤔

#

hmm?

#

a plugin

#

oh darn...

sturdy oar
#

Oh then it's normal to have weird stuff after decompilation

stoic shell
#

heh

odd knoll
#

My eyes. They burn.

sturdy oar
#

Haven't you ever looked at mojang's decompiled code

odd knoll
#

var1 and var2 here.

stoic shell
#

currently fixing the one below that, changing stained glass data 8 => light gray stained glass

#

alright, here we have:

#
    private void OpenPlayMenu(Player player) {
        Inventory inv = Bukkit.createInventory(null, 45, this.saves.menuTitle);
        inv.setItem(10, GeneralMethods.CreateItem(this.saves.playButtons.get(0).title, this.saves.playButtons.get(0).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(12, GeneralMethods.CreateItem(this.saves.playButtons.get(1).title, this.saves.playButtons.get(1).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(28, GeneralMethods.CreateItem(this.saves.playButtons.get(2).title, this.saves.playButtons.get(2).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(30, GeneralMethods.CreateItem(this.saves.playButtons.get(3).title, this.saves.playButtons.get(3).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(14, GeneralMethods.CreateItem(this.saves.playButtons.get(4).title, this.saves.playButtons.get(4).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(16, GeneralMethods.CreateItem(this.saves.playButtons.get(5).title, this.saves.playButtons.get(5).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(32, GeneralMethods.CreateItem(this.saves.playButtons.get(6).title, this.saves.playButtons.get(6).lore, this.saves.buttonMaterial, this.saves.buttonData));
        inv.setItem(34, GeneralMethods.CreateItem(this.saves.playButtons.get(7).title, this.saves.playButtons.get(7).lore, this.saves.buttonMaterial, this.saves.buttonData));

        for (int i = 0; i < 45; ++i) {
            if (i != 10 && i != 12 && i != 28 && i != 30 && i != 14 && i != 16 && i != 32 && i != 34) {
                inv.setItem(i, GeneralMethods.CreateItem("", null, Material.LIGHT_GRAY_STAINED_GLASS_PANE));
            }
        }

        player.openInventory(inv);
    }```
past star
#

I can't download java because it costs money aparently

sturdy oar
#

It's free

#

You need link?

boreal tiger
#

omg whats that attrocity

odd knoll
#

You probably just need to find the archive page.

stoic shell
#

so now...

past star
#

I have a link

stoic shell
#

I need that button data in the material

sturdy oar
#

You're probably looking at the Oracle page

odd knoll
sturdy oar
#

Dude no don't install Oracle stuff

odd knoll
#

wtf, they removed java 8 from that.

past star
#

Oh

stoic shell
#

cause I've removed the data constructor as there is no data in modern versions

sturdy oar
#

PLEASE USE THIS JDK
https://adoptopenjdk.net/

AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully open source set of build scripts and infrastructure. Supported platforms include Linux, macOS, Windows, ARM, Solaris, and AIX.

odd knoll
#

I have an oracle account coz I found it rly annoying trying to find the DL pages.

subtle blade
#

Oracle has a different license

#

I second opting for Adopt

stoic shell
#

So now how am I gonna get that "buttonData" in the buttonMaterial?

odd knoll
#

O, what's the benefit of not using oracle?

subtle blade
#

Adopt was acquired by Eclipse Foundation recently as well iirc

odd knoll
#

So not a massive corporate entity that's trying to control the internet space.

subtle blade
#

It's an open source implementation of the Java platform. Oracle's licensing changes are a bit more limiting so a lot of people jumped to OpenJDK instead

#

AdoptOpenJDK is primarily just a set of open source scripts that builds OpenJDK and distributes binaries for you

#

Though really, as far as the average user should be concerned, it's Java

stoic shell
#

Personally, I use AdoptOpenJDK.

subtle blade
#

lol

stoic shell
#

but any thoughts on my problem?

subtle blade
#

idk what buttonData is

#

Looks constant though

stoic shell
#

oh

#

didn't show the code did I...

sturdy oar
#

I use Azul Zulu JDK for development

#

I have my reasons

stoic shell
#

sorry, was trying to replace the many iterator and while loops with enhanced for, lol

#

public int buttonData;

#

this.buttonData = conf.getInt("Menu.Item.Data");

subtle blade
#

So it's configurable. Though again, there's no data. Can be deleted

stoic shell
#
   Item:
      Material: STAINED_CLAY
      Data: 1```
#

so first, that should be terracotta....

#

then I can just remove Data and ButtonData and I'll be fine?

subtle blade
#

Yep

#

You'd have to update the material in the config to the appropriate value though

#

(because stained clay doesn't exist obviously)

stoic shell
#

yeah I just did

subtle blade
#

oki Then you're good to go

stoic shell
#

well I'm still removing data and button data

#

oh wait

#

I would also change terracotta to ORANGE_TERRACOTTA, since that's what data 1 was for stained clay

knotty karma
#

Will I be notified when my premium resource is approved/denied? (or will I need to check on the page every once in a while to see)
Sorry if this is answered somewhere else, I've looked through all the docs I could find and saw nothing on how I'd be notified on any approval updates.

past star
#

I got java and beacon still wont work

stoic shell
#

no red now there, so that's good

past star
#

Does it not work anymore?

subtle blade
#

I actually don't remember if you're notified when approved. You'll be notified if it's rejected, that's for sure.

past star
#

Does beacon still work?

knotty karma
#

OK, thanks. I guess I'll keep checking every once in a while then lol

past star
#

I have the right Java version and its still mad at me

stoic shell
#

alright, now I am fixing some more data value usages that showed up

unborn jewel
#

This is confusing me how am I suppose use this ```java
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}

stoic shell
#

👀

#

dunno, haven't meddled with permissions recently

lone fog
#

Use vault API preferably

stoic shell
#

alright...

unborn jewel
#

Hm

stoic shell
#

10 errors left

#

now in another class

#

let's see...

unborn jewel
#

@lone fog do i need to use maven with vault?

lone fog
#

You don't need to

unborn jewel
#

Ok

stoic shell
#

I've got 2 data value/int usage errors, 1 material name error, and 7 duplicate variable errors.

past star
#

What is another way of allowing my friends to join my world, because Beacon isnt working

unborn jewel
#

Im gonna need help with vault api permission thing

stoic shell
#

oh wait, before I get to that, I noticed a possible bug

#

if (game.state.equals(TheBridge.GameState.Playing) && e.getBlock().getType().equals(Material.TERRACOTTA) && this.IsInsideTheBuildBorder(e.getBlock().getLocation(), game)) {

#

Will this catch all colors of terracotta?

subtle blade
#

No because TERRACOTTA doesn't exist

stoic shell
#

it does

#

actually

subtle blade
#

wat

lament sonnet
#

You know when u join a server u get like a second of invulnerability? Would there be any way to disable it if that be with a plugin. because people on my server are abusing it like crazy.

stoic shell
#

lol

subtle blade
#

oh there's just regular terracotta, you're right

#

Well, no, that wouldn't cover them all. You'd have to create an EnumSet constant of all the types of terracotta and check against that instead

stoic shell
#

oh

#

srsly

subtle blade
#

private static final Set<Material> TERRACOTTA_BLOCKS = EnumSet.of(Material.RED_TERRACOTTA, /* yes, this again */);
TERRACOTTA_BLOCKS.contains(block.getType())

stoic shell
#

.-.

subtle blade
#

There's no vanilla Tag for it you can refer to unfortunately so you have to make your own lol

stoic shell
#

well, I've got code for the DYE_TO_TERRACOTTA, which used code that did something like that

lament sonnet
#

😠

stoic shell
#

oh

#

oops

#

that's exactly what you were describing and what I need, lol

#

😄

subtle blade
#

Pretty much the same thing only you're creating another constant and it's a Set instead of a Map

stoic shell
#

oh

#

yeah...

subtle blade
#

(because you don't need those DyeColor mappings)

unborn jewel
#

Does vault have a support discord?

stoic shell
#

1 sec, making a util class to put it in

#

got it

#

hmm, what am I changing...

tiny pebble
#
a:
  b:
  - c
  - d
ab:

In this situation, how would I check if b exists? Supposedly it doesn't register as a ConfigurationSection, I assume due to the variables underneath

#

I've tried both
config.getConfigurationSection("a").isConfigurationSection("b")
config.isConfigurationSection("a.b")
Both return false.

kindred bane
#

b would be considered a list

tiny pebble
#

Then is there a way I can check whether or not it is there?

kindred bane
#

I believe there is a contains method

halcyon snow
tiny pebble
#

i mean, upon going there i found isList was a thing, so I'd assume that could work

kindred bane
#

isList method documentation: "If the path exists but is not a List, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a List and return appropriately."

stoic shell
#

😄 I may have got the Set done right

tiny pebble
#

Interestingly enough it worked at first with isList, then once the list was added to, it was no longer recognized as a list

lament sonnet
#

Any way to disable spawn invulnerability when you join the server?

stoic shell
#

@subtle blade Is this right?

    public static final Set<Material> TerracottaColorSet = new EnumSet<>;

    static {
        for (final DyeColor color : DyeColor.values()) {
            try {
                final Material terraMaterial = Material.valueOf(color.name() + "_TERRACOTTA");
                TerracottaColorSet.add(terraMaterial);
            } catch (final Exception error) {
                Bukkit.getLogger().info("Error forming TerracottaColorSet:");
                error.printStackTrace();
            }
        }
    }```
#

Oh wait no, my ide says no to new EnumSet<>;

#
    public static final Set<Material> TerracottaColorSet = EnumSet.noneOf(Material.class);

    static {
        for (final DyeColor color : DyeColor.values()) {
            try {
                final Material terraMaterial = Material.valueOf(color.name() + "_TERRACOTTA");
                TerracottaColorSet.add(terraMaterial);
            } catch (final Exception error) {
                Bukkit.getLogger().info("Error forming TerracottaColorSet:");
                error.printStackTrace();
            }
        }
    }```
This should fix it
opal heron
#

Is it possible for a citizens npc to place blocks when its stuck? im guessing no since in Dreams way he used a hacked client to make an AI that hunts you down like a player. (cant say the name for obvious reasons.)

Dream made a plugin that allows a player to move on its own or hunt you down, he used a hacked client so it can place blocks on its own without controlling it if u didnt know wtf terminator im talking about.

#

Also i know the terminator wasnt an npc, a player. Just wanna do a replica

stoic shell
#

Alright, used it and it seems to work, moving on

tiny pebble
#

So here's an interesting problem.
For context, I have a command that allows me to add an item to a list in a YamlConfiguration. I also have a command to remove an item from the list.

Upon reload, I can add an item to the list, and there is now an item in the list. If I add another, it instead replaces the item rather than adding. Although, if I reload and then add another item, it will add another just as I wanted.

If I reload and remove the item, the entire section of the list will delete, as wanted. Though, if I don't reload and remove the item, only what's inside the list will delete, leaving me with list: [] rather than null, or nothing, just like I want.

So, TL;DR, I can not do edit my list more than once without reloading between each edit. Is there anything I can do to work around this? I have a method to reload the configuration file, and I do that after every edit as well, although it doesn't work as wished for.

#

If needed, here is the part that matters of my class: https://hastebin.com/ifuximuwug.js

Although, I'm not sure it will help since I don't think it has to do with my code... although it may, I have no idea. I just think it's reload being wonky.

stoic shell
#

now I'm fixing the duplicate variables...

frigid ember
#

i cant use buildtools all of a sudden

#

i used to be able to fine

stoic shell
#

it looks like someone went through and half-of-the-time removed String when making string variables, and used msg1 for different things consecutively

tiny pebble
#

Maybe if anyone knows what part of the server needs to be reloaded for my commands to... well, work? That way I could at least try to figure out a way to individually reload that part.

stoic shell
#

for me, idk

tiny pebble
#

I'll make a post on the forums since I don't want this to get lsot

grim halo
#

@tiny pebble You should not write the item directly in the file.
On runtime you use a List<ItemStack> on shutdown you save the list to a yml file on enable you load the list from the
yml again and from there on use the given List for further manipulation until the next shutdown

tiny pebble
#

I have it written directly into the file as I want the users to be able to edit the permissions through the configuration file as well as through commands.

Should I have it go through a medium of some sort?

grim halo
#

What permissions? You wanted to maintain a List of ItemStacks right?

tiny pebble
#

List of strings 😛

#

I specified "item" just meaning... anything

#

was just a placeholder

#

sorry bout that miscommunication

grim halo
#

Ah ok.

buoyant path
#

whats the best packet armorstand API out there, I want one where I can set the item in hand, teleport, and have multiple lines

#

I don't want to use holographic displays because it has many extra things that I don't need for my project

flat topaz
#

Can I have some help aka therapy to fix my sleep schedule?

tiny pebble
#

That's not what this discord is for

flat topaz
#

Oh

buoyant path
#

lol

grim halo
#

@flat topaz Listen to an audiobook in darkness. Thats what i do to get tired.

flat topaz
#

Ok I’ll try it lol

grim halo
#

@tiny pebble Holy this code is literally unreadable...

buoyant path
#

what are you reading

#

?

grim halo
tiny pebble
#

hahaha yeah i figured.. i'm only 4 months into coding. it's understandable for me but i know that it's very disorganized and could be put together much better

#

its a whole mess and i'm sorry for that haha

stoic shell
#

6 more errors to go...

tiny pebble
#

i could post the whole class although i doubt that'll make anything better..

tiny pebble
#

that is one of the many known rookie mistakes indeed

stoic shell
#

alright...

tiny pebble
#

i planned on keeping it like that then ending up fixing it once it gets actually working

#

that is why i hesitated showing my code at all lol

#

i doubt it really helps

grim halo
#

Nah my code also looked like this in the first two weeks.

tiny pebble
#

well i've only been coding since quarantine and haven't done all too much with it. also completely self-taught lol

#

although my dad works with this stuff so he offered to help me get it organized and provide feedback on what i did that was gross

stoic shell
#

I'm assuming the old Material.LONG_GRASS is now Material.TALL_GRASS. Am I right?

grim halo
#

My recommendation is that you first embrace the concept of early exit
eg
if(args.length <= 2){
// message
return
}

tiny pebble
#

i was debating that, although i want it to send many different messages to specify the problem the command had

stoic shell
#

5 errors now. Getting close.

grim halo
#

You can still do that.
You can keep exactly the same functionality as now but way more readable.

tiny pebble
#

ah okay, i'll reorganize it as such then in the morning ahha

#

you think i should ask the forums? probably after i reorganize it haha

buoyant path
#

ask about?

tiny pebble
#

@grim halo just tagging you since you're the one that looked at it, curious about your input about me posting it. sorry for the ping

stoic shell
#

4 errors.

keen compass
#

soon you will have 6

#

XD

stoic shell
#

What why?

#

It's actually 4 left to solve.

tiny pebble
#

i think he's just screwing with ya

quartz trench
#

tanku what are you going to post about

stoic shell
#

3 errors

quartz trench
#

just return early like 7smile said

tiny pebble
keen compass
#

yes I am just messing with you @stoic shell

tiny pebble
#

my organization i'll fix later 😅

keen compass
#

however one day you will encounter that scenario where you think you have a small amount of errors left

#

and then you change something and voila 10 more errors just popped up XD

buoyant path
#

lol

quartz trench
#

The solution is you load the list from yaml

buoyant path
#

So does anyone have a recommendation for a packet armorstand API ?

quartz trench
#

and store it memory and maniulate it, and save it when you need to

#

dont directly edit the yaml list

stoic shell
#

oh lol

#

just 2 errors

#

1 is just a simple variable name fix

#

second I'll need help with

tiny pebble
#

@quartz trench How exactly would I go about loading the list from the yaml..? I honestly thought that's what I was getting it lmfao

stoic shell
#

1 error!

keen compass
#

@tiny pebble I see you are still on the same problem lmao

stoic shell
#

😄

tiny pebble
#

it's the weirdest problem i have ever encountered, yes

keen compass
#

personally I would just store it as a string in yaml separated with ,

stoic shell
#

alright so now, the last problem

quartz trench
#

thats another way to approach it

tiny pebble
#

i might have to resort to that, yeah

stoic shell
#
   @EventHandler
   void onBuild(BlockPlaceEvent event) {
      Player player = event.getPlayer();
      if (this.main.playersInGames.containsKey(player.getName())) {
         Game game = (Game)this.main.gamesList.get(this.main.playersInGames.get(player.getName()));
         event.setCancelled(true);
         if (game.state.equals(TheBridge.GameState.Playing) && !this.blackListedBlocks.contains(event.getBlock().getType()) && event.getBlock().getType().equals(Material.TERRACOTTA) && this.IsInsideTheBuildBorder(event.getBlock().getLocation(), game)) {
            ItemStack item = event.getItemInHand();
            if (item != null) {
               player.getInventory().setItem(player.getInventory().getHeldItemSlot(), GeneralMethods.CreateItem(Material.TERRACOTTA, 64, item.getData().getData()));
            }

            event.setCancelled(false);
         }
      }
   }```
#

The line of focus is
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), GeneralMethods.CreateItem(Material.TERRACOTTA, 64, item.getData().getData()));

quartz trench
#

or just addAll the getStringList from yaml to a list, clear it on reload, and if its empty on save then save null instead of empty list

stoic shell
#

How do I put that data in the Material, since there isn't Data anymore?

tiny pebble
#

ah i see

stoic shell
#

wait a moment

#

nvm

#

lol

tiny pebble
#

thank you so much @quartz trench , my brain has been fried for a concerning amount of time because i didn't know how yaml's worked lmao

stoic shell
#

this is just the same as the rest of the terracotta with data => terracotta material with color I think

frigid ember
stoic shell
#

nvm again, lol

#

I don't have the color

buoyant path
#

Snoopy I recommend not using hashmaps like that, make a user class that stores all your data, then put those in just one hashmap

#

having collections that big is probably not good on your performance

stoic shell
#

huh?

#

where in there is a hashmap?

buoyant path
#

if (this.main.playersInGames.containsKey(player.getName())) {

#

have a hashmap of users

#

and do

stoic shell
#

oh

buoyant path
#

user.isInGame()

stoic shell
#

this isn't my original plugin

#

my concern right now is getting it to compile first :p

buoyant path
#

lol

stoic shell
#

Do you know how I can put that data in the material?

#

or get the color from the item somehow?

buoyant path
#

I usually do 1.8 so if its a higher version i wouldnt know

quartz trench
#

what version snoopy

stoic shell
#

1.16.1

#

is what I am trying to get this working on

quartz trench
#

I think you need to do material.toString and check it for a color name yourself

buoyant path
#

if it is on 1.8 you could use an enummap of byte as key and a custom Color enum as a value

quartz trench
#

and to get the colored material use Material.of("color" + Material.terracotta)

stoic shell
#

material...

#

I have an item

buoyant path
#

item.getData should return materialdata

#

which may have a color

#

Im not sure

quartz trench
#

materialdata is deprecated in 1.16

#

different color blocks are different materials

buoyant path
#

then the color value would be in item.getType().name()

quartz trench
#

or material.toString() for terracotta, wool, etc

#

for dyed armor and stuff its different

stoic shell
#

wait

#

.getType().name() would give me an item name, is that right?

buoyant path
#

it would be like

#

IRON_BARS

#

or smth

#

so you replace the name of the matieral

#

and then it will give the color

quartz trench
#

not sure, test it. but getType returns Material and I think .getName() on Material is the same as toString()

#

and yeah do what iron man says. .getType().toString().replace("TERRACOTTA", "") and then you have color

stoic shell
#

nvm

#

all I needed was that .getType.name()

#

that's really what I was needing

#

and...

#

ugh

#

1 more error popped up.

#

Fixed.

#

YAY!

keen compass
#

now time to find the bugs

#

😄

stoic shell
#

lol

#

alright, lemme put this in my plugins...

#

and starting...

#

bruh

#

java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.BED

#

I know exactly the problem, lol.

#

I forgot to change BED in the config to RED_BED

#

Oh look, I fixed that and it started and enabled successfully! 🎉

#
[19:56:27 INFO]: [TheBridge] Enabling TheBridge v1.0.0
[19:56:27 INFO]: [TheBridge] Your server is running version v1_16_R1
[19:56:27 INFO]: [TheBridge] Plugin enabled!```
tiny pebble
#

@quartz trench Curious, is what you told me to do the same as:

List<String> list = config.getStringList(path);
list.add(var);
config.set(path, var);

???
If not that's fine, just asking since that's what I did prior. Though I've edited it a tad

stoic shell
#

Well, that took all day...

marsh hawk
#

so whats up with player#getOpenInventory(); ? it always returns the same thing lol

buoyant path
#

you sure?

#

it may return the same OpenInventory class or whatever but its contents are most likely different

#

Ive used it in the past

marsh hawk
#

always returns InventoryType of Crafting

#

no matter what i have open

buoyant path
#

you must be checking the wrong player, or its async and may not be updated perfectly

quartz trench
#

@tiny pebble it's not really the same try ```java
//field in config class
private final List<String> list = new ArrayList<>();
//in your reload/load config method
list.clear();
list.addAll(config.getStringList(path));
//in your save method
config.set(path, list);

tiny pebble
#

ahhh okay

keen compass
#

@marsh hawk are you storing the reference of the inventory ?

#

if so, you need to update the reference otherwise you will only get the same inventory

marsh hawk
#

oh thats interesting

wet bronze
#

Does anybody know a better plugin loader/unloader than AutoPluginLoader? It crashed my server when I tried unloading a plugin, and PlugMan is outdated.

tiny pebble
#

@quartz trench

list.clear();
list.addAll(usersConfig.getStringList(uuid + ".permissions"));
list.add(name);
usersConfig.set(uuid + ".permissions", list);
usersConfig.save(Main.getInstance().getUsersConfigFile());

I've tried something like this and have ended with the same result I kept getting: it replaces the list with the new value rather than adding to the list with the new value.

I know you said to put it in my reload config function, though I'm unable to as I require a UUID from the user from the command event.

wet bronze
#

@quick arch Will that let me unload plugins seamlessly? Because there's a plugin on my server screwing with Movecraft and I can't keep restarting my server to see which plugin it is because it takes 10 minutes for it to start up.

quick arch
#

no idea, haven't tried it yet

quartz trench
#

Pluginmanager and similar stuff breaks a lot of plugins

#

would not reccomend tbh

#

restart the server fully when changing plugins

wet bronze
#

I've tried making a separate server on my PC to debug so it doesn't affect my players but the plugin decides to work on that server with the exact same plugins and folders.

#

The only plugins/folders I don't copy are the dynamic map and towny ones because they're fucking huge and if they're what's screwing with movecraft, I can't get rid of them since they're essential to the server.

quick turtle
#
    public void end() {
        for (EnvoyDrop drop : envoyDrops) {
            world.getBlockAt(drop.getDropLocation()).setType(Material.AIR);
            envoyHolograms.get(drop).remove();
        }

        envoyDrops.clear();
        envoyHolograms.clear();

        HandlerList.unregisterAll(envoyListener);
        endCountdown.cancel();
        plugin.getAPI().beginEnvoyCountdown();

        // TODO: send message
    }

I need that to run when the plugin disables, but it seems I cant do any of that in onDisable

tiny pebble
#

alright so

#

list.addAll() returned as empty after the list was empty. could be getting the path wrong...?

quick arch
#

MoveCraft?

#

That?

#

That's relatively old 🤔

#

Despite it being called "Big Doors", there's a plane flying across the first image

quick turtle
#

I fixed my problem

#

lol wat

tiny pebble
#

alright im just gonna jump off a cliff man

#

addAll just doesnt even addAll

#

erdtuyuhijop ive broken my brain too much

spice loom
#

why does that not get rid of potion effects?

#

it's a command

#

no errors

subtle blade
#

getActivePotionEffects() is not mutable

#

player.getActivePotionEffects().forEach(e -> player.removePotionEffect(e.getType()))

spice loom
#

ah gotcha thanks

tiny pebble
#

ok cool so now my list just resets itself when i do it idk whats going on anymore man

#

so when I run list.clear() it seems to clear the list it is being based off of as well, although I did addAll() I never made them.. the same??

#
private final List<String> list = new ArrayList<>();

if (...) {
  list.clear(); // List = []

  player.sendMessage(permList.toArray(new String[0])); // sends me the list, proving that the list exists and is a list

  list.addAll(permList); // List SHOULD = permList's values, but list = []
  // I have also tried:
  // list.addAll(Arrays.asList(permList.toArray(new String[0])));
  list.add(args); // list adds args
  config.set(path, list); // permList is set to list...
  config.save(configFile); 
}

I also printed the list after running list.clear() and it was just.... []

#

what in the world is happening

#

why am i so dumb

stoic shell
#

huh...

#

The start of the bugs with the plugin I updated

keen compass
#

at this point you would probably be better off showing all your code @tiny pebble lol

stoic shell
#

any ideas?

tiny pebble
#

are you sure you want to see my monstrosity

stoic shell
#

I've looked the error and relevant code over and I don't see why the material would be null...

keen compass
#

in onClick event material is null @stoic shell

stoic shell
#

well yeah

#

I've established that :p

keen compass
#

well it is possible that where someone clicks

#

is nothing

#

should check to ensure that what is being clicked isn't Air 😉

tiny pebble
keen compass
#

Could separate this out between a few classes

stoic shell
#

but I'm the right item

tiny pebble
#

yeah i could but i wasn't sure how to go about that seeing as it was all the same command

keen compass
#

not sure about you being the right item

stoic shell
#

the thing is, it was working for the first few clicks, and now anything I click is null

keen compass
#

@tiny pebble I will give you a link to an example

tiny pebble
#

neato

keen compass
stoic shell
#

see

#

I clicked the wool a few times and no errors

tiny pebble
#

thanks 😛

stoic shell
#

then I click a few more and then all the clicks stop working

#

and error

tiny pebble
#

btw line 161 is where my issue starts.
line 173 is where the list stuff starts

keen compass
#

so instead of trying to do this in the command class

#

why don't you cache your configs at the start of the server

stoic shell
#

Here is a snippet of the area in OpenGameSettingsSizeMenu:

            int i;
            for (i = 0; i < game.GetTeamsCount(); ++i) {
                TeamBridge teamBridge = game.teams.get(i);
                TeamColor teamColor = new TeamColor("&f", "Not setup yet", Color.WHITE, DyeColor.WHITE);
                if (teamBridge.color != -1) {
                    teamColor = Saves.teamColors.get(teamBridge.color);
                }

                DyeColor dyeColor = teamColor.getDyeColor();
                Material terracottaMaterial = DYE_TO_TERRACOTTA.get(dyeColor);

                ItemStack it = GeneralMethods.CreateItem(ChatColor.DARK_PURPLE.toString() + (i + 1) + ". team", GeneralMethods.arrayToList(new String[]{teamColor.getChatColor() + teamColor.getTeamName()}), terracottaMaterial);
                it.setAmount(teamBridge.color + 2);
                inv.setItem(teamColorSlots[i], it);
            }```
tiny pebble
#

how would i manage to get the target users UUID then 🤔

keen compass
#

you don't need to know that stuff to cache it

stoic shell
#

why would terracottaMatterial suddenly start being null...

tiny pebble
#

how exactly would i cache it then?
the exact path of the list i want to get involves the uuid which is why i put it in my command class

keen compass
#

I understand

#

but you don't need to know which UUID's you want to cache the UUID's ahead of time

#

You can parse through your yaml file for configuration sections

#

and cache the data based on what it is for

#

So since you have UUID's not hard to create a HashMap with the key being UUID's

#

value being whatever is stored for said UUID

#

now anytime you want data for that UUID, it is just a matter of looking at the hashmap

tiny pebble
#

is this more-so for an organization type thing / easier access or would that hypothetically solve my problem?

keen compass
#

this is where you learn to organize your data 😉

#

It would do both

tiny pebble
#

ah i see

keen compass
#

so instead of accessing the config file everytime

#

you access the hashmap

#

or a custom object

#

you can have custom objects that you put into hashmaps too 😛

tiny pebble
#

i'll have to learn how to cache the config, but other than that i think i could do it

#

could make a function for all this too so i don't have to write line after line of editing the list? shrug

#

but thank you for putting up with my nonsense, i've been trying to solve this problem literally the entire day and i'm just so exhausted haha

sage fiber
#

Hi everyone! Quick question, does anyone know of a plugin that keeps chunks active if there's a chest minecart with items in it?

keen compass
#

@tiny pebble it is a good learning experience

tiny pebble
#

right now im just setting up the hashmap then im just gonna go to bed 😂

keen compass
#

just because something exists in the API doesn't always mean it works like it is suppose to or doesn't come without problems. So when that happens, roll your own solutions 😛

tiny pebble
#

i'll get up early to work on it tmrw

#

that's a fair explanation 🙂

keen compass
#

may not create the best thing to solve it, but once you solve it

#

you can always work on making it better 😉

tiny pebble
#

thank you 🙂

keen compass
#

Well do what you can, also of note can always make it open source as well maybe others might make some PR's 😛

#

but, regardless some of us are always here to help lol

tiny pebble
#

yeah and i'm glad i found a server that helps me even with the little experience i have

keen compass
#

I have been helping people since nearly the beginning of MC XD

tiny pebble
#

damn, that's quite impressive

keen compass
#

now if I can just get my post count up, maybe I can apply for staff for spigot 😛

tiny pebble
#

good luck!

keen compass
#

used to be Bukkit Dev Staff now maybe its time to try my hand at some point being spigotmc staff 😉

tiny pebble
#

i think you'd get it, but i know nothing about the spigot staff branch haha 😛

keen compass
#

there is a prerequisite you have to meet before you can apply

#

I am more interested in being resource staff then anything else

stoic shell
#

huh...

#

strange thing is that I can't find any code doing anything when the 2 team setup wool are clicked

tiny pebble
#

i've not quite sure what the staff here do other than help us out, seeing as that's all i participate in with this community 😅

stoic shell
#

all the rest of the items in the settings have checks

#

but I can't find any code checking for a click on the team setup wool

keen compass
#

ah, so a ghost bug

#

those are always fun

#

lets hope it doesn't resolve itself before you figure out the cause of it 😛

#

because then that is even more confusing then having the bug originally XD

stoic shell
#

no it won't

lone fog
#

Isn’t FileConfiguration already a cache technically

#

Or does that read the file each time you call a method

grim halo
#

FileConfiguration is basically a glorified hashmap

keen compass
#

it is, but it isn't the same as using a hashmap

lone fog
#

That’s what I figured

stoic shell
#

ohohoh

#

I found the code 😄

tiny pebble
#

well, i have the users UUID and permissions shoved into a hashmap, now i just gotta figure out how to add to the value of the hashmap. but that's for another day, because sleep is pretty neat

stoic shell
#

but I still can't find why Material is null .-.

tiny pebble
#

also have a function to update the hashmap ^-^

stoic shell
#

oh...

#
                if (teamBridge.color != -1) {
                    teamColor = Saves.teamColors.get(teamBridge.color);
                }```
keen compass
#

hashmap already has a function to update it

stoic shell
#

the teamColor could be null if something is going wrong with saving, couldn't it?

keen compass
#

color ends up being negative?

#

o.O

stoic shell
#

uh

#

apparently...

keen compass
#

wonder where that magic value is coming from

stoic shell
#

snippet:

grim halo
#

also if its a int then it cant be null

stoic shell
#
         } else if (e.getView().getTitle().startsWith("Game Settings: ")) {
            gameName = (String)listener.main.editMode.get(player.getName());
            game = (Game)listener.main.gamesList.get(gameName);
            if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
               buttonName = item.getItemMeta().getDisplayName();
               e.setCancelled(true);
               if (buttonName.equals(ChatColor.DARK_PURPLE.toString() + "1. team")) {
                  color = item.getAmount() - 2;
                  if (e.isLeftClick() && color > 0) {
                     --((TeamBridge)game.teams.get(0)).color;
                  } else if (e.isRightClick() && color < Saves.teamColors.size() - 1) {
                     ++((TeamBridge)game.teams.get(0)).color;
                  }

                  listener.main.OpenGameSettingsSizeMenu(player);```
#

check repeats 4 times for 2. 3. and 4.

#

see anything weird here?

keen compass
#

yes a bunch of magic values

stoic shell
#

huh?

keen compass
#

magic values are hardcoded numbers

stoic shell
#

oh

keen compass
#

leaving no meaning in where they are being derived

#

or their purpose

stoic shell
#

oh huh

#

any idea to the source of the issue though?

keen compass
#

does it check for 0

grim halo
#

what issue?

stoic shell
#

huh?

keen compass
#

well your first snippet checks if it isn't equal to -1

stoic shell
#

what is the "it" you refer to?

grim halo
#

did you register it?

lyric cypress
#

wdym

keen compass
#

Implement Listener and make sure you register your event class in your onEnable()

stoic shell
#

extended version of first snippet:

lyric cypress
#

I am implementing listener

grim halo
#

Did you register an instance of your Listener class with the PluginManager?

lyric cypress
#

oh yeah that part

stoic shell
#
       if (this.editMode.containsKey(player.getName())) {
            String gameName = this.editMode.get(player.getName());
            Game game = this.gamesList.get(gameName);
            Inventory inv = Bukkit.createInventory(null, 45, "Game Settings: " + gameName);
            int[] teamColorSlots = new int[]{10, 12, 14, 16};

            int i;
            for (i = 0; i < game.GetTeamsCount(); ++i) {
                TeamBridge teamBridge = game.teams.get(i);
                TeamColor teamColor = new TeamColor("§f", "Not setup yet", Color.WHITE, DyeColor.WHITE);
                if (teamBridge.color != -1) {
                    teamColor = Saves.teamColors.get(teamBridge.color);
                }

                DyeColor dyeColor = teamColor.getDyeColor();
                Material terracottaMaterial = DYE_TO_TERRACOTTA.get(dyeColor);

                ItemStack it = GeneralMethods.CreateItem(ChatColor.DARK_PURPLE.toString() + (i + 1) + ". team", GeneralMethods.arrayToList(new String[]{teamColor.getChatColor() + teamColor.getTeamName()}), terracottaMaterial);
                it.setAmount(teamBridge.color + 2);
                inv.setItem(teamColorSlots[i], it);
            }
        (...)
lyric cypress
#

ty

#

Wait actually in the same class

@EventHandler
    public void onInventoryDrag(final InventoryDragEvent e) {
        if (e.getInventory() == inv) {
            e.setCancelled(true);
        }
    }

this works fine

grim halo
#

sysout in the beginning of the method to see if it fires.

stoic shell
#

so if it's not setup, it makes a white terracotta

lyric cypress
#

InventoryDrag fires, closeInventory doesn't

stoic shell
#

but the other snippet changes, the color, and then calls the method again, right?

keen compass
#

I still don't understand where -1 comes from o.O

#

such an unusual check lol

stoic shell
#

uh

#
public class TeamBridge {
   public int color = -1;
   public Location spawn;
   public Location respawn;
   public Location pit;
   public List<String> gamePlayers = new ArrayList();
   public PointsEntry entryPit = new PointsEntry();
   int scorePoints = 0;
   public Team teamDisplay;
   public TeamColor teamColor;```
#

default?

grim halo
#

@lyric cypress Not possible. Every method that is annotated with EventHandler and has exactly one argument of type Event will be registered and fires.

tiny pebble
#

i just meant whenever the value of the hashmap changes then update it, or is the value and the hashmap forever linked? lmao idk how it works entirely im tired

stoic shell
#

so there's the -1

keen compass
#

Values in the hashmap don't update automatically

tiny pebble
#

aight that’s what i meant when i made the function that updates it

keen compass
#

ah ok

lyric cypress
#
@EventHandler
    public void closeInventory(final InventoryCloseEvent event) {
        Bukkit.broadcastMessage("closeInventory firing");

this doesn't log anything

#

when i close my inventory

stoic shell
#

hmm

#

so there's gotta be something wrong with this:

#
                  color = item.getAmount() - 2;
                  if (e.isLeftClick() && color > 0) {
                     --((TeamBridge)game.teams.get(0)).color;
                  } else if (e.isRightClick() && color < Saves.teamColors.size() - 1) {
                     ++((TeamBridge)game.teams.get(0)).color;
                  }

                  listener.main.OpenGameSettingsSizeMenu(player);```
#

but idk what

grim halo
#

@lyric cypress But you have another eventhandler method in the same class that fires?

lyric cypress
#

yes

grim halo
#

Show me the class...

#

And the part where you register the listener

lyric cypress
#
public class RewardStorage implements Listener {
    public Inventory inv;

    public RewardStorage() {
        inv = Bukkit.createInventory(null, 9, ChatColor.GOLD + "Unclaimed Rewards");
    }

    public void openInventory(HumanEntity ent) {
        ent.openInventory(inv);
    }

    @EventHandler
    public void onInventoryClick(final InventoryClickEvent e) {
        Bukkit.broadcastMessage("this fires");
    }
    
    @EventHandler
    public void closeInventory(final InventoryCloseEvent event) {
        Bukkit.broadcastMessage("this doesn't");
    }
}
grim halo
#

Not possible. Did you make sure to export this version and copy it into your plugin dir?

lyric cypress
#

yes

stoic shell
#

hmm

#

I added debug logging

#
                if (teamBridge.color != -1) {
                    teamColor = Saves.teamColors.get(teamBridge.color);
                    Bukkit.getLogger().info(String.valueOf(teamBridge.color));
                }
#

I right clicked... and 0

#

then the Material error

grim halo
#

InventoryCloseEvent does not fire if the player closes his own Inventory. Did you only test it with the player inventory?

lyric cypress
#

I tested it with player inventory and this inventory

keen compass
#
                  if (e.isLeftClick() && color > 0) {
                     --((TeamBridge)game.teams.get(0)).color;
                  } else if (e.isRightClick() && color < Saves.teamColors.size() - 1) {
                     ++((TeamBridge)game.teams.get(0)).color;
                  }

this check is flawed

stoic shell
#

now I'll try logging getDyeColor

keen compass
#

specifically the second portion of it is flawed

grim halo
#

So you are telling me that if you open any chest, click in slots then close it.
You will see "this fires" for clicks and nothing else?

lyric cypress
#

yes

#

I had more stuff in there but I removed it

grim halo
#

That is completely impossible.

lyric cypress
#

I mean it is firing so

#

not impossible

stoic shell
#

AHA

#

welp

#

that explains why Material is null

grim halo
#

So do both events fire?

stoic shell
#

getDyeColor is null

#

lol

lyric cypress
#

no only InventoryClickEvent

stoic shell
#

and getColor gives me Color:[rgb0xED2828]

#

so now the question is... why is getDyeColor() returning null?

keen compass
#

well getColor and DyeColor are two separate things

#

you can have color for something but not have dyecolor

stoic shell
#

I get the dyecolor from the color...

#

wait what

#

I thought it should approximate?

lyric cypress
#

oh wait actually

grim halo
#

@lyric cypress There are only 2 possiblities here.

  1. You dont show your whole code.
  2. You got a broken Spigot version (which i doubt)
lyric cypress
#

I'm looking at the wrong vlass

#

class

#

sorry

#

I have similarly named things

stoic shell
#

huh...

#

alright so...

#

I've calculated the dyecolor with DyeColor.getByColor(color);

#

I thought this would approximate, why isn't it?

#

oh...

#

alright, so how can I approximate?

keen compass
#

would have to know the ranges

#

I don't know the range of DyeColor in relation to the range of Color

stoic shell
#

how have people done this previously?

keen compass
#

But essentially you need to know the range of DyeColor so you know how to tell what your color is closer to as far as DyeColor goes

#

I am not sure

#

I don't normally mess with DyeColors 😛

#

I just know that you can have a color but not a DyeColor lol

grim halo
#
    /**
     * Represents white dye.
     */
    WHITE(0x0, 0xF, Color.fromRGB(0xF9FFFE), Color.fromRGB(0xF0F0F0)),
    /**
     * Represents orange dye.
     */
    ORANGE(0x1, 0xE, Color.fromRGB(0xF9801D), Color.fromRGB(0xEB8844)),
    /**
     * Represents magenta dye.
     */
    MAGENTA(0x2, 0xD, Color.fromRGB(0xC74EBD), Color.fromRGB(0xC354CD)),
    /**
     * Represents light blue dye.
     */
    LIGHT_BLUE(0x3, 0xC, Color.fromRGB(0x3AB3DA), Color.fromRGB(0x6689D3)),
    /**
     * Represents yellow dye.
     */
    YELLOW(0x4, 0xB, Color.fromRGB(0xFED83D), Color.fromRGB(0xDECF2A)),
    /**
     * Represents lime dye.
     */
    LIME(0x5, 0xA, Color.fromRGB(0x80C71F), Color.fromRGB(0x41CD34)),
    /**
     * Represents pink dye.
     */
    PINK(0x6, 0x9, Color.fromRGB(0xF38BAA), Color.fromRGB(0xD88198)),
    /**
     * Represents gray dye.
     */
    GRAY(0x7, 0x8, Color.fromRGB(0x474F52), Color.fromRGB(0x434343)),
    /**
     * Represents light gray dye.
     */
    LIGHT_GRAY(0x8, 0x7, Color.fromRGB(0x9D9D97), Color.fromRGB(0xABABAB)),
    /**
     * Represents cyan dye.
     */
    CYAN(0x9, 0x6, Color.fromRGB(0x169C9C), Color.fromRGB(0x287697)),
    /**
     * Represents purple dye.
     */
    PURPLE(0xA, 0x5, Color.fromRGB(0x8932B8), Color.fromRGB(0x7B2FBE)),
    /**
     * Represents blue dye.
     */
    BLUE(0xB, 0x4, Color.fromRGB(0x3C44AA), Color.fromRGB(0x253192)),
    /**
     * Represents brown dye.
     */
    BROWN(0xC, 0x3, Color.fromRGB(0x835432), Color.fromRGB(0x51301A)),
    /**
     * Represents green dye.
     */
    GREEN(0xD, 0x2, Color.fromRGB(0x5E7C16), Color.fromRGB(0x3B511A)),
    /**
     * Represents red dye.
     */
    RED(0xE, 0x1, Color.fromRGB(0xB02E26), Color.fromRGB(0xB3312C)),
    /**
     * Represents black dye.
     */
    BLACK(0xF, 0x0, Color.fromRGB(0x1D1D21), Color.fromRGB(0x1E1B1B));

From DyeColor enum

stoic shell
#

yes....?

keen compass
#

there you go

stoic shell
#

um what am I doing with that?

grim halo
#

the get by color is a Map<Color, DyeColor>
So you need the exact color

keen compass
#

So, that contains your range

#

just turn them into ints and do a < > to see what is closer to what 😉

stoic shell
#

.-.

grim halo
#

Also Guava has a RangeMap
You can create a RangeMap<Integer, Integer> and have a lookup table for your colors

keen compass
#

ah didn't know that, good news is Guava is shaded into the server jar

#

so you only need to add it as dependency for your project, but no shading needed 😛

#

think spigot uses Guava 23?

stoic shell
#

I still have no clue on how to turn those words into actual code .-.

grim halo
#

Think so yes

keen compass
#

You get the enum values

#

which is going to be Hex

grim halo
keen compass
#

but you can't do range check with Hex at least I don't think you can, so you use the method to get their Int values instead

#

and then use the method as specified above to do a range check

grim halo
#

Ok here is what you can do.

  1. Create a Comparator<DyeColor> that compares the DyeColor values by their color field (ascending or descending)
  2. Create a PriorityQueue or some other sorted collection that assures sorted iteration.
  3. Iterate and create a range between current and next element (thats your color range)
  4. Use the range in a RangeMap or use <> comparisons
#

To be honest to do this you need quite some experience with Java

stoic shell
#

nvm

#

I'm just changing the config to take a dye color 🙂

grim halo
#

I wouldnt bother with int values anyways...

#

Wait... is your color int maybe just the index of the DyeColor enum?

stoic shell
#

omg it's working 😄

#

eh I just changed the config to take DyeColor, not RGB

keen compass
#

lol

#

looks like you will get to learn some quirks with the API 😛

#

never assume anything

#

XD

marsh hawk
#

I have literally no plugins installed on my server and the server keeps switching from day to night each second

#

im very confused

fringe cairn
#

Do I need to create a new class file for every command I add? or whats the right way of adding commands

marsh hawk
#

It's good practice to have a separate class for each command.

#

you dont have to

#

but It makes it much easier to read through when your plugin grows

frigid ember
#

Anyone know where i can find code to make portals between a hub server... PVP and Survival and Event

marsh hawk
#

theres plenty on the plugin store, just decompile one of them

stoic shell
#

Alright, I gotta get some sleep...

#

but the mechanics of the plugin are broken

#

lol

atomic folio
#

Como se crea un server spigot?

subtle blade
#

Didn't I answer this earlier?

quartz trench
#

sounds like it might be in your plugin.yml but not registered in your onEnable

subtle blade
#

Or is this a different person

slim hemlock
#

is there a way to use a TextComponent ClickEvent to just run a method or create an object? I was bypassing it by running commands but admins don't like getting console messages about players clicking these

subtle blade
slim hemlock
subtle blade
#

Yeah basically

#

also, fuck you, I have to listen to the whole thing now

slim hemlock
#

I charge for that you know

#

also answer my question bby

subtle blade
#

I don't think there is another way aside from what you suggested - commands

slim hemlock
#

bollocks

subtle blade
#

Have you actually assigned the command executor to your command?

#

because there is no possible condition where that would display the usage

#

@slim hemlock Does intercepting the PlayerCommandPreprocessEvent and cancelling it still throw out the message to the log?

slim hemlock
#

you know that's what I was thinking about

#

but I was also wondering if that could be considered to be malicious behavior

#

since it's obfuscating commands

subtle blade
#

I don't think so. Just make it some arbitrary command

#

Like /helloimmagmaguyandthisisacommandusedfortextcomponents

#

lol

#

Cloud, your braces seem all out of whack. You're missing a brace on the args.length condition

slim hemlock
#

eh at least for now I'll let admins know they can huff my shorts if they don't like the tracking commands

#

I'll reconsider it if too many people show up to huff them

jaunty night
#

Is there any way to hook into the cave generator using spigot?

grim halo
#

Cloud... this was answered two times now.

#

Its immutable.

    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }
#

getActivePotionEffects() does not return the actual List of effects

#

I thought you wanted to remove all effects from the player.

#

Yes. Also use early escapes.
eg
if(!commandSender.hasPermission("perm")){
return;
}
This way your code gets way more readable.

frigid ember
#

is PlayerDeathEvent#setKeepInventory(true) supposed to still have the items drop?

#

im currently using it, and i get the items dropped where i died and also i keep them, thus duplicating

marsh hawk
grim halo
#

Wouldnt make much sense.

frigid ember
#

yeah right?

#

maybe its a bug

grim halo
#

you coudl try getDrops().clear()

fleet crane
#

Isn’t this literally in the javadocs

frigid ember
#

ah

fleet crane
#

It’s even bolded

frigid ember
#

yea

#

alright thanks

buoyant path
#

Anyone know of a Packet Armorstand API that has support for equipment, like item on head, (plus the head rotation), also Item in hand, and arm pose

#

Ive asked many times today, sorry for bothering but this is very important to my project right now

grim halo
#

Do you want completely packet based Armorstands?

buoyant path
#

yes

#

they are much more effective for performance, especially when needing to teleport them

grim halo
#

Do you need to teleport them a lot?

buoyant path
#

this is what I need to do

#

which requires teleportation at least once per tick

grim halo
#

Is there a reason you dont just use fake items and teleport them accordingly?

marsh hawk
#

^

#

probably less laggy than armorstands

buoyant path
#

I dont believe you can make them have anti gravity

#

and also there is still a component needed with armorstands

#

its part of the animation before that

pastel arrow
#

You can set Item's velocity to 0 so no gravity.

buoyant path
#

you would have to constantly do that

#

which is essentially the same issue

grim halo
#

Maybe you can even extend the NMS item and let it not be affected by gravity.
You can still send spawn and teleport packets for those then

buoyant path
#

Well that would be the reason I'm in need of an API, im not great with nms, I can do it, but Im sure an API will provide something much better quality that I wont be able to make because of lack of experience.

#

Obviously I could gain that experience but ideally I dont want to spend 2 weeks on this

#

its just part of the loot system on my server

grim halo
buoyant path
#

that solves only part of the problem, I would still need a way to set the head pose of the armorstand because there is a segment before the gif that uses an armorstand, and can only happen with an armorstand

grim halo
#

I dont know any API for this... What version are you on?

buoyant path
#

1.8

grim halo
#

If you code for a 6 years old version you need to be prepared to do everything on your own.

nimble stump
#

Just extend armor stand

#

The same way you would have extended the item

#

Or just use a normal armor stand

buoyant path
#

lol if minecraft would make a good combat update I would be able to move to a newer version, but even then, there are no sufficient armorstand apis

#

Alex, the problem is performance

nimble stump
#

So use packets

buoyant path
#

I will attempt to make it with normal entities

#

for now

nimble stump
#

Packets aren’t that difficult to use

buoyant path
#

depends on which ones :p

nimble stump
#

You’re unlikely to find an API for what is a very specific use case

buoyant path
#

PacketPlayOutEntityMetadata is pretty bad lmfao

nimble stump
#

Why

#

What’s so bad about it for you

buoyant path
#

theres no documentation, and I have no Idea how to change the name of an entity with it

#

I've looked at protocol

nimble stump
buoyant path
#

nothing that offers anything

#

lmao

nimble stump
#

You just need documentation of the entity metadata packet?

buoyant path
#

I've looked at this before

#

it doesnt provide much help

#

for what I needed

nimble stump
#

What part are you missing

#

Because that has all the meta data information you could possibly need

buoyant path
#

Just look at the 3rd value of type field, it says string and doesnt provide any notes, I believed that was the name but I guess not

#

it doesn't matter anymore but im just saying packets arent always EASY

nimble stump
#

The type field is just what type the value is

#

Not a specific piece of metadata

#

So if the value was a string, the type would be that byte

#

To tell the client “hey this value I’m sending is a string, decode it like this”

buoyant path
#

2 OptChat Custom name empty
3 Boolean Is custom name visible false

nimble stump
#

Yes

buoyant path
#

this is all I had and when I tried to send that with the data watcher, it kicked me from the game

nimble stump
#

So you were sending what as index

#

OptChat isn’t a string

#

It’s a boolean followed by optional Chat

frigid ember
#

how do i sort a Set<>

buoyant path
#

Collections.sort?

strange forge
#

depends on your type, but create an ArrayList copy then use #sort() or Collections#sort

#

would be smth like
List<X> list = new ArrayList<>(your set);
Collections.sort(list);
do magic with list or convert it to a set once again

buoyant path
#

dont you need to provide a comparator?

grim halo
#

You cant really sort a Set unless its something like a SortedSet or LinkedHashSet