Skip to content

Commit

Permalink
Fix merge artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
FireInstall committed Jan 28, 2024
1 parent a59b45e commit ec92d64
Show file tree
Hide file tree
Showing 99 changed files with 278 additions and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,33 @@ public class SelectCommand implements ICommand {
return "select";
}

@Override
public @NotNull String[] getAliases() {
return null;
}

@Override
public boolean canBeConsole() {
return false;
}

@Override
public String getDescription() {
public @NotNull Component getDescription() {
return "select and clear region selections";
}

@Override
public @NotNull String[] getParameters() {
return new String[]{
"1",
"2",
"clear"
};
}

@Override
public @NotNull String[] getUsage() {
public @NotNull Component getUsage() {
return new String[]{
"/minigame select 1",
"/minigame select 2",
"/minigame select clear"
};
}

@Override
public String getPermissionMessage() {
return "You don't have permission to modify regions";
}

@Override
public @Nullable String getPermission() {
return "minigame.region.select";
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @Nullable Minigame minigame,
String label, @NotNull String @Nullable [] args) {
@NotNull String @Nullable [] args) {
if (sender instanceof Player player) {
MinigamePlayer mgPlayer = Minigames.getPlugin().getPlayerManager().getMinigamePlayer(player);

Expand Down Expand Up @@ -94,7 +75,7 @@ public boolean onCommand(@NotNull CommandSender sender, @Nullable Minigame minig
}

@Override
public @Nullable List<@NotNull String> onTabComplete(CommandSender sender, Minigame minigame, String alias, String[] args) {
public @Nullable List<@NotNull String> onTabComplete(@NotNull CommandSender sender, Minigame minigame, String[] args) {
if (args != null && args.length == 1) {
return MinigameUtils.tabCompleteMatch(List.of("1", "2", "clear"), args[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean canBeConsole() {
}

@Override
public Component getUsage() { // todo create", "remove", "type", "time
public Component getUsage() {
return MinigameMessageManager.getMgMessage(MgCommandLangKey.COMMAND_SET_FLOORDEGEN_USAGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean canBeConsole() {
}

@Override
public @NotNull Component getDescription() { //todo delete to remove
public @NotNull Component getDescription() {
return MinigameMessageManager.getMgMessage(MgCommandLangKey.COMMAND_SET_REGENAREA_DESCRIPTION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import au.com.mineauz.minigames.objects.IndexedMap;
import au.com.mineauz.minigames.objects.StrIntMapPersistentDataType;
import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -44,9 +43,9 @@ public MenuItem(@NotNull Component name, @Nullable List<@NotNull Component> desc
this.displayItem.setItemMeta(meta);
}

public MenuItem(@NotNull String name, @NotNull ItemStack displayItem) {
public MenuItem(@NotNull Component name, @NotNull ItemStack displayItem) {
ItemMeta meta = displayItem.getItemMeta();
meta.setDisplayName(ChatColor.RESET + name);
meta.displayName(name);
displayItem.setItemMeta(meta);
this.displayItem = displayItem;
}
Expand Down Expand Up @@ -140,7 +139,7 @@ public void setDescriptionPartAtIndex(@NotNull String typeStr, int postion,
startingPoint += length;
} else {
// well crap. invalid data!
Minigames.log().warning("Found empty description data. Ignoring it for now.");
Minigames.getCmpnntLogger().warn("Found empty description data. Ignoring it for now.");
//todo we need a iterator of IndexedMap --> code it!
}
}
Expand Down Expand Up @@ -179,7 +178,7 @@ private static void removeDescriptionPart(@NotNull ItemMeta itemMeta, @NotNull I
startingPoint += entryBefore.getValue();
} else {
// well crap. invalid data!
Minigames.log().warning("Found empty description data. Ignoring it for now.");
Minigames.getCmpnntLogger().warn("Found empty description data. Ignoring it for now.");
//todo we need a iterator of IndexedMap --> code it!
}
}
Expand All @@ -192,12 +191,12 @@ private static void removeDescriptionPart(@NotNull ItemMeta itemMeta, @NotNull I
}
} else {
// well crap. invalid data!
Minigames.log().severe("Menu item has empty lore but tried to remove a part of it. Clearing all parts mow. Please open an Issue!");
Minigames.getCmpnntLogger().error("Menu item has empty lore but tried to remove a part of it. Clearing all parts mow. Please open an Issue!");
descriptionRegistry.clear();
}
} else {
// well crap. invalid data!
Minigames.log().warning("Menu item trying to remove empty description data.");
Minigames.getCmpnntLogger().warn("Menu item trying to remove empty description data.");
descriptionRegistry.remove(typeStr);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import au.com.mineauz.minigames.managers.language.MinigameMessageType;
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

Expand All @@ -12,12 +13,12 @@ public class MenuItemAddFlag extends MenuItem {

private final Minigame mgm;

public MenuItemAddFlag(String name, Material displayItem, Minigame mgm) {
public MenuItemAddFlag(Component name, Material displayItem, Minigame mgm) {
super(name, displayItem);
this.mgm = mgm;
}

public MenuItemAddFlag(String name, List<String> description, Material displayItem, Minigame mgm) {
public MenuItemAddFlag(Component name, List<Component> description, Material displayItem, Minigame mgm) {
super(name, description, displayItem);
this.mgm = mgm;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import au.com.mineauz.minigames.minigame.TeamColor;
import au.com.mineauz.minigames.minigame.modules.TeamsModule;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import net.kyori.adventure.text.Component;
import org.apache.commons.text.WordUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand All @@ -19,7 +20,7 @@ public class MenuItemAddTeam extends MenuItem {

private final TeamsModule tm;

public MenuItemAddTeam(String name, Minigame minigame) {
public MenuItemAddTeam(Component name, Minigame minigame) {
super(name, MenuUtility.getCreateMaterial());
tm = TeamsModule.getMinigameModule(minigame);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import au.com.mineauz.minigames.managers.language.MinigameMessageType;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
Expand All @@ -11,9 +12,9 @@
public class MenuItemAddWhitelistBlock extends MenuItem {
private final List<Material> whitelist;

public MenuItemAddWhitelistBlock(String name, List<Material> whitelist) {
public MenuItemAddWhitelistBlock(Component name, List<Material> whitelist) {
super(name, MenuUtility.getCreateMaterial());
setDescriptionStr(List.of("Left Click with item to", "add to whitelist/blacklist", "Click without item to", "manually add item."));
setDescription(List.of("Left Click with item to", "add to whitelist/blacklist", "Click without item to", "manually add item."));
this.whitelist = whitelist;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.bukkit.inventory.ItemStack;

public class MenuItemBack extends MenuItem {

private final Menu prev;

public MenuItemBack(Menu prev) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import au.com.mineauz.minigames.managers.language.MinigameMessageType;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand All @@ -16,13 +17,13 @@
public class MenuItemBlockData extends MenuItem {
private Callback<BlockData> dataCallback;

public MenuItemBlockData(String name, Material displayItem) {
public MenuItemBlockData(Component name, Material displayItem) {
super(name, displayItem);
dataCallback.setValue(displayItem.createBlockData());
setDescription(createDescription(dataCallback.getValue()));
}

public MenuItemBlockData(String name, Material displayItem, Callback<BlockData> callback) {
public MenuItemBlockData(Component name, Material displayItem, Callback<BlockData> callback) {
super(name, displayItem);
this.dataCallback = callback;
setDescription(createDescription(dataCallback.getValue()));
Expand All @@ -36,7 +37,7 @@ public void update() {
/**
* minecraft:chest[facing=north,type=single,waterlogged=false]{Items:[{Slot:0b,id:"minecraft:grass_block",Count:1b}],Lock:""}
*/
private List<String> createDescription(BlockData data) {
private List<Component> createDescription(BlockData data) {
List<String> result = new ArrayList<>();
result.add("Material: " + data.getMaterial().name());
String dataString = data.getAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public void updateDescription() {
} else {
col = ChatColor.RED + "false";
}
if (getDescriptionStr() != null) {
description = getDescriptionStr();
String desc = ChatColor.stripColor(getDescriptionStr().get(0));
if (getDescription() != null) {
description = getDescription();
String desc = ChatColor.stripColor(getDescription().get(0));

if (desc.matches("true|false"))
description.set(0, col);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class MenuItemComponent extends MenuItem {
protected Callback<String> stringCallback; // todo I'm not happy having String as callback here. I need it since the SerializeableBridge can't use Components, but this doesn't feel right.
private boolean allowNull = false;

public MenuItemComponent(String name, Material displayItem, Callback<String> stringCallback) {
public MenuItemComponent(Component name, Material displayItem, Callback<String> stringCallback) {
super(name, displayItem);
this.stringCallback = stringCallback;
updateDescription();
}

public MenuItemComponent(String name, List<String> description, Material displayItem, Callback<String> stringCallback) {
public MenuItemComponent(Component name, List<Component> description, Material displayItem, Callback<String> stringCallback) {
super(name, description, displayItem);
this.stringCallback = stringCallback;
updateDescription();
Expand All @@ -44,7 +44,7 @@ public void updateDescription() {
// setting = setting.substring(0, 17) + "...";
//}

description = getDescriptionComp();
description = getDescription();
if (description != null) {
//todo find a way to not overwrite other descriptions
//Component desc = description.get(0);
Expand All @@ -59,7 +59,7 @@ public void updateDescription() {
description.add(settingComp);
}

setDescriptionComp(description);
setDescription(description);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import au.com.mineauz.minigames.managers.language.MinigameMessageType;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
Expand All @@ -11,15 +12,14 @@
import java.util.List;

public class MenuItemDecimal extends MenuItem {

protected final Callback<Double> value;
private final double lowerInc;
private final double upperInc;
private final Double min;
private final Double max;
protected DecimalFormat form = new DecimalFormat("#.##");

public MenuItemDecimal(String name, Material displayItem, Callback<Double> value,
public MenuItemDecimal(Component name, Material displayItem, Callback<Double> value,
double lowerInc, double upperInc, Double min, Double max) {
super(name, displayItem);
this.value = value;
Expand All @@ -30,7 +30,7 @@ public MenuItemDecimal(String name, Material displayItem, Callback<Double> value
updateDescription();
}

public MenuItemDecimal(String name, List<String> description, Material displayItem, Callback<Double> value,
public MenuItemDecimal(Component name, List<Component> description, Material displayItem, Callback<Double> value,
double lowerInc, double upperInc, Double min, Double max) {
super(name, description, displayItem);
this.value = value;
Expand All @@ -46,10 +46,10 @@ public void setFormat(DecimalFormat format) {
}

public void updateDescription() {
List<String> description;
if (getDescriptionStr() != null) {
description = getDescriptionStr();
String desc = ChatColor.stripColor(getDescriptionStr().get(0));
List<Component> description;
if (getDescription() != null) {
description = getDescription();
String desc = ChatColor.stripColor(getDescription().get(0));

if (desc.matches("-?[0-9]+(?:.[0-9]+)?")) {
description.set(0, ChatColor.GREEN + form.format(value.getValue()));
Expand All @@ -67,7 +67,7 @@ public void updateDescription() {
}
}

setDescriptionStr(description);
setDescription(description);
}

@Override
Expand Down
Loading

0 comments on commit ec92d64

Please sign in to comment.