Towny Classic

Towny Classic

3.2k Downloads

ItemLists newBuilder() is filling ItemLists with all Materials (except Legacy_)

LlmDl opened this issue ยท 0 comments

commented

What steps will reproduce the problem?

Add

@EventHandler
public void onBuild(TownyBuildEvent e) {
System.out.println("Build Event");
	new Throwable().printStackTrace();
}

To a listener.

Be told that a TownyBuildEvent is being thrown by com.palmergames.bukkit.towny.listeners.TownyPlayerListener.onPlayerInteract(TownyPlayerListener.java:424)

Add the following debug:

System.out.println("1 " + String.valueOf(ItemLists.CANDLES.contains(item) && clickedMat == Material.CAKE));
System.out.println("2 " + String.valueOf(ItemLists.PLANTS.contains(item) && clickedMat == Material.FLOWER_POT));
System.out.println("3 " + String.valueOf(item == Material.HONEYCOMB && ItemLists.WEATHERABLE_BLOCKS.contains(clickedMat)));
System.out.println("4 " + String.valueOf(ItemLists.PLACEABLE_BOOKS.contains(item) && ItemLists.BOOK_CONTAINERS.contains(clickedMat)));
System.out.println("5 " + String.valueOf(item == Material.BONE_MEAL));
if (ItemLists.CANDLES.contains(item) && clickedMat == Material.CAKE ||  
	ItemLists.PLANTS.contains(item) && clickedMat == Material.FLOWER_POT ||
	item == Material.HONEYCOMB && ItemLists.WEATHERABLE_BLOCKS.contains(clickedMat) ||
	ItemLists.PLACEABLE_BOOKS.contains(item) && ItemLists.BOOK_CONTAINERS.contains(clickedMat) ||
	item == Material.BONE_MEAL) {

	if (!TownyActionEventExecutor.canBuild(player, loc, item))
		event.setCancelled(true);
	return;
}

Be told that 4 is always true.

Discover that because of

	public static Builder<Material, ItemLists> newBuilder() {
		return new Builder<>(Registry.MATERIAL, Material.class, ItemLists::new).notStartsWith("LEGACY_");
	}

all ItemLists using newBuilder() are pre-loaded with every Material except the LEGACY_ materials.

I solved it by just removing the .notStartsWith("LEGACY_") but I'm not sure if that's ideal.

What is the expected output?

ItemLists should only ever have what is included in them using the factory methods.

Towny version

latest

Server version

na

Please use Pastebin.com to link the following files

  1. Your full server startup from the logs\latest.log:
  2. Your Towny config.yml:
  3. Your townyperms.yml:
  4. Your log's error:

(optional) If this is to do with permissions,
5. Your permissions file:

(optional) If this is to do with chat,
6. Your chatconfig.yml:
7. Your channels.yml: