localized various gui parts

This commit is contained in:
Flemmli97 2021-05-02 22:00:05 +02:00
parent ecd50b8ec1
commit 0c7a58d3af
9 changed files with 71 additions and 48 deletions

View File

@ -1,3 +1,17 @@
Flan 1.3.0
======================
- Fix inventory desync when using the naming screen
- Add /flan help command. For now it only displays all available commands
- Add default groups. Set via the config file in defaultGroups.
Every claim created will have those groups by default to make group creation easier
and without having to make the same group for multiple claims again and again.
- Add personal groups. Set either via the command /flan permissions personal ...
or via the gui /flan personalGroups.
Personal groups are just like default groups except player bound. If a player has any
personal groups that will be used instead of the global default group. That way the player
can also specify what groups a claim should have upon creation.
- Localized various gui strings
Flan 1.2.6
======================
- Fix giveClaimBlocks not working for players that never joined the server

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G
loader_version=0.9.1+build.205
# Mod Properties
mod_version = 1.2.6
mod_version = 1.3.0
maven_group = com.flemmli97.flan
archives_base_name = flan

View File

@ -87,6 +87,26 @@ public class LangConfig {
public String screenEnableText = "Enabled: %s";
public String screenUneditable = "Non Editable!";
public String screenClose = "Close";
public String screenNext = "Next";
public String screenPrevious = "Prev";
public String screenAdd = "Add";
public String screenBack = "Back";
public String screenMenu = "Claim-Menu";
public String screenMenuSub = "SubClaim-Menu";
public String screenMenuGlobal = "Edit Global Permissions";
public String screenMenuGroup = "Edit Permissiongroups";
public String screenMenuDelete = "Delete Claim";
public String screenConfirm = "Confirm";
public String screenYes = "Yes";
public String screenNo = "No";
public String screenGroupPlayers = "%s-Players";
public String screenRemoveMode = "Remove Mode: %s";
public String screenGlobalPerms = "Global-Permissions";
public String screenGroupPerms = "%s-Permissions";
public String screenPersonalGroups = "Personal-Groups";
public String screenPersonalPermissions = "Personal Permissions for %s";
public LangConfig(MinecraftServer server) {
File configDir = FabricLoader.getInstance().getConfigDir().resolve("flan").toFile();

View File

@ -38,7 +38,7 @@ public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler {
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText(claim.parentClaim() != null ? "SubClaim-Menu" : "Claim-Menu");
return PermHelper.simpleColoredText(claim.parentClaim() != null ? ConfigHandler.lang.screenMenuSub : ConfigHandler.lang.screenMenu);
}
};
player.openHandledScreen(fac);
@ -50,22 +50,22 @@ public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler {
switch (i) {
case 0:
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Close").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenClose).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, close);
break;
case 2:
ItemStack perm = new ItemStack(Items.BEACON);
perm.setCustomName(new LiteralText("Edit Global Permissions").setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
perm.setCustomName(new LiteralText(ConfigHandler.lang.screenMenuGlobal).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
inv.setStack(i, perm);
break;
case 3:
ItemStack group = new ItemStack(Items.WRITABLE_BOOK);
group.setCustomName(new LiteralText("Edit Permissiongroups").setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
group.setCustomName(new LiteralText(ConfigHandler.lang.screenMenuGroup).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
inv.setStack(i, group);
break;
case 8:
ItemStack delete = new ItemStack(Items.BARRIER);
delete.setCustomName(new LiteralText("Delete Claim").setStyle(Style.EMPTY.withFormatting(Formatting.RED)));
delete.setCustomName(new LiteralText(ConfigHandler.lang.screenMenuDelete).setStyle(Style.EMPTY.withFormatting(Formatting.RED)));
inv.setStack(i, delete);
break;
default:

View File

@ -1,6 +1,7 @@
package com.flemmli97.flan.gui;
import com.flemmli97.flan.claim.PermHelper;
import com.flemmli97.flan.config.ConfigHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
@ -35,7 +36,7 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler {
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText("Confirm");
return PermHelper.simpleColoredText(ConfigHandler.lang.screenConfirm);
}
};
player.openHandledScreen(fac);
@ -48,12 +49,12 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler {
switch (i) {
case 3:
ItemStack yes = new ItemStack(Items.GREEN_WOOL);
yes.setCustomName(new LiteralText("Yes").setStyle(Style.EMPTY.withFormatting(Formatting.GREEN)));
yes.setCustomName(new LiteralText(ConfigHandler.lang.screenYes).setStyle(Style.EMPTY.withFormatting(Formatting.GREEN)));
inv.setStack(i, yes);
break;
case 5:
ItemStack no = new ItemStack(Items.RED_WOOL);
no.setCustomName(new LiteralText("No").setStyle(Style.EMPTY.withFormatting(Formatting.RED)));
no.setCustomName(new LiteralText(ConfigHandler.lang.screenNo).setStyle(Style.EMPTY.withFormatting(Formatting.RED)));
inv.setStack(i, no);
break;
default:

View File

@ -45,7 +45,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText(group + "-Players");
return PermHelper.simpleColoredText(String.format(ConfigHandler.lang.screenGroupPlayers, group));
}
};
player.openHandledScreen(fac);
@ -60,15 +60,15 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, close);
} else if (i == 3) {
ItemStack stack = new ItemStack(Items.ANVIL);
stack.setCustomName(new LiteralText("Add").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenAdd).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
inv.setStack(i, stack);
} else if (i == 4) {
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText("Remove Mode: " + this.removeMode).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -123,7 +123,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
if (index == 4) {
this.removeMode = !this.removeMode;
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText("Remove Mode: " + this.removeMode).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
slot.setStack(stack);
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
return true;

View File

@ -4,6 +4,7 @@ import com.flemmli97.flan.api.ClaimPermission;
import com.flemmli97.flan.api.PermissionRegistry;
import com.flemmli97.flan.claim.Claim;
import com.flemmli97.flan.claim.PermHelper;
import com.flemmli97.flan.config.ConfigHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
@ -59,7 +60,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText(group == null ? "Global-Permissions" : String.format("%s-Permissions", group));
return PermHelper.simpleColoredText(group == null ? ConfigHandler.lang.screenGlobalPerms : String.format(ConfigHandler.lang.screenGroupPerms, group));
}
};
player.openHandledScreen(fac);
@ -74,15 +75,15 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
int page = (int) additionalData[2];
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, close);
} else if (page == 1 && i == 47) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText("Prev").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
inv.setStack(i, close);
} else if (page == 0 && i == 51) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText("Next").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
inv.setStack(i, close);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -103,20 +104,20 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
this.slots.get(i).setStack(close);
} else if (i == 47) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page >= 1) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText("Prev").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
}
this.slots.get(i).setStack(stack);
} else if (i == 51) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page < maxPages) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText("Next").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
}
this.slots.get(i).setStack(stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)

View File

@ -2,6 +2,7 @@ package com.flemmli97.flan.gui;
import com.flemmli97.flan.api.PermissionRegistry;
import com.flemmli97.flan.claim.PermHelper;
import com.flemmli97.flan.config.ConfigHandler;
import com.flemmli97.flan.player.PlayerClaimData;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@ -38,7 +39,7 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler {
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText("Personal-Groups");
return PermHelper.simpleColoredText(ConfigHandler.lang.screenPersonalGroups);
}
};
player.openHandledScreen(fac);
@ -51,15 +52,15 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, close);
} else if (i == 3) {
ItemStack stack = new ItemStack(Items.ANVIL);
stack.setCustomName(new LiteralText("Add").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenAdd).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
inv.setStack(i, stack);
} else if (i == 4) {
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText("Remove Mode: " + this.removeMode).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -107,7 +108,7 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler {
if (index == 4) {
this.removeMode = !this.removeMode;
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText("Remove Mode: " + this.removeMode).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
slot.setStack(stack);
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
return true;

View File

@ -3,6 +3,7 @@ package com.flemmli97.flan.gui;
import com.flemmli97.flan.api.ClaimPermission;
import com.flemmli97.flan.api.PermissionRegistry;
import com.flemmli97.flan.claim.PermHelper;
import com.flemmli97.flan.config.ConfigHandler;
import com.flemmli97.flan.player.PlayerClaimData;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@ -46,22 +47,7 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler {
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText(String.format("Personal Permissions for %s", group));
}
};
player.openHandledScreen(fac);
}
private static void openClaimMenu(PlayerEntity player, String group, int page) {
NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() {
@Override
public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) {
return new PersonalPermissionScreenHandler(syncId, inv, group, page);
}
@Override
public Text getDisplayName() {
return PermHelper.simpleColoredText(String.format("Personal Permissions for %s", group));
return PermHelper.simpleColoredText(String.format(ConfigHandler.lang.screenPersonalPermissions, group));
}
};
player.openHandledScreen(fac);
@ -78,15 +64,15 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler {
int page = (int) additionalData[1];
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
inv.setStack(i, close);
} else if (page == 1 && i == 47) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText("Prev").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
inv.setStack(i, close);
} else if (page == 0 && i == 51) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText("Next").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
inv.setStack(i, close);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -109,20 +95,20 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
this.slots.get(i).setStack(close);
} else if (i == 47) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page >= 1) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText("Prev").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
}
this.slots.get(i).setStack(stack);
} else if (i == 51) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page < maxPages) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText("Next").setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
}
this.slots.get(i).setStack(stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)