1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Added several new strings for translation

* Cargo node connector messages now also show up in the actionbar!

* /sf stats and /sf researching can no longer be used if researching is
disabled.

* If researching is disabled the guide will no longer contain settings
for research-related options
This commit is contained in:
TheBusyBiscuit 2022-07-19 19:47:30 +02:00
parent 5d5decbf45
commit aa74958837
10 changed files with 69 additions and 34 deletions

View File

@ -48,6 +48,9 @@
#### Changes
* Tree Growth Accelerators can now actually cause the Tree to fully grow (1.17+ only)
* Slimefun now requires Java 16
* "Connected / Not connected" messages for cargo nodes are now sent via the actionbar
* "/sf stats" can no longer be used if researching is disabled
* "/sf research" can no longer be used if researching is disabled
#### Fixes
* Fixed #3597

View File

@ -8,6 +8,7 @@ import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@ -28,6 +29,7 @@ import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
@ -57,7 +59,9 @@ public class GPSNetwork {
private final Map<UUID, Set<Location>> transmitters = new HashMap<>();
private final TeleportationManager teleportation = new TeleportationManager();
private final ResourceManager resourceManager;
private final SlimefunLocalization locale;
/**
* This constructs a new {@link GPSNetwork}.
@ -68,6 +72,7 @@ public class GPSNetwork {
*/
public GPSNetwork(@Nonnull Slimefun plugin) {
resourceManager = new ResourceManager(plugin);
locale = Slimefun.getLocalization();
}
/**
@ -141,24 +146,24 @@ public class GPSNetwork {
* The {@link Player}
*/
public void openTransmitterControlPanel(@Nonnull Player p) {
ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
ChestMenu menu = new ChestMenu(ChatColor.BLUE + locale.getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
for (int slot : border) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, im -> {
im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
im.setDisplayName(ChatColor.GRAY + locale.getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
im.setLore(null);
}));
menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler());
int complexity = getNetworkComplexity(p.getUniqueId());
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + getStatusText(p, complexity), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + locale.getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + locale.getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
openWaypointControlPanel(pl);
return false;
@ -200,8 +205,8 @@ public class GPSNetwork {
*
* @return An icon for this waypoint
*/
@Nonnull
public ItemStack getIcon(@Nonnull String name, @Nonnull Environment environment) {
@ParametersAreNonnullByDefault
public @Nonnull ItemStack getIcon(String name, Environment environment) {
if (name.startsWith("player:death ")) {
return HeadTexture.DEATHPOINT.getAsItemStack();
} else if (environment == Environment.NETHER) {
@ -213,15 +218,24 @@ public class GPSNetwork {
}
}
@ParametersAreNonnullByDefault
private @Nonnull String getStatusText(Player player, int complexity) {
if (complexity > 0) {
return "&2&l" + locale.getMessage(player, "gps.status-online");
} else {
return "&4&l" + locale.getMessage(player, "gps.status-offline");
}
}
public void openWaypointControlPanel(@Nonnull Player p) {
PlayerProfile.get(p, profile -> {
ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
ChestMenu menu = new ChestMenu(ChatColor.BLUE + locale.getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
for (int slot : border) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&7" + locale.getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + locale.getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(2, (pl, slot, item, action) -> {
openTransmitterControlPanel(pl);
return false;
@ -231,7 +245,7 @@ public class GPSNetwork {
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + locale.getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
menu.addMenuClickHandler(6, ChestMenuUtils.getEmptyClickHandler());
int index = 0;
@ -274,11 +288,11 @@ public class GPSNetwork {
PlayerProfile.get(p, profile -> {
if ((profile.getWaypoints().size() + 2) > inventory.length) {
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.max", true);
locale.sendMessage(p, "gps.waypoint.max", true);
return;
}
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.new", true);
locale.sendMessage(p, "gps.waypoint.new", true);
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F);
ChatInput.waitForPlayer(Slimefun.instance(), p, message -> addWaypoint(p, message, l));
@ -302,7 +316,7 @@ public class GPSNetwork {
PlayerProfile.get(p, profile -> {
if ((profile.getWaypoints().size() + 2) > inventory.length) {
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.max", true);
locale.sendMessage(p, "gps.waypoint.max", true);
return;
}
@ -315,7 +329,7 @@ public class GPSNetwork {
for (Waypoint wp : profile.getWaypoints()) {
if (wp.getId().equals(id)) {
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.duplicate", true, msg -> msg.replace("%waypoint%", event.getName()));
locale.sendMessage(p, "gps.waypoint.duplicate", true, msg -> msg.replace("%waypoint%", event.getName()));
return;
}
}
@ -323,7 +337,7 @@ public class GPSNetwork {
profile.addWaypoint(new Waypoint(profile, id, event.getLocation(), event.getName()));
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 1F);
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.added", true);
locale.sendMessage(p, "gps.waypoint.added", true);
}
});
});

View File

@ -33,6 +33,12 @@ class ResearchCommand extends SubCommand {
@Override
public void onExecute(CommandSender sender, String[] args) {
// Check if researching is even enabled
if (!Slimefun.getRegistry().isResearchingEnabled()) {
Slimefun.getLocalization().sendMessage(sender, "messages.researching-is-disabled");
return;
}
if (args.length == 3) {
if (!(sender instanceof Player) || sender.hasPermission("slimefun.cheat.researches")) {
Optional<Player> player = PlayerList.findByName(args[1]);

View File

@ -23,6 +23,12 @@ class StatsCommand extends SubCommand {
@Override
public void onExecute(CommandSender sender, String[] args) {
// Check if researching is even enabled
if (!Slimefun.getRegistry().isResearchingEnabled()) {
Slimefun.getLocalization().sendMessage(sender, "messages.researching-is-disabled");
return;
}
if (args.length > 1) {
if (sender.hasPermission("slimefun.stats.others") || sender instanceof ConsoleCommandSender) {
Optional<Player> player = PlayerList.findByName(args[1]);

View File

@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
class FireworksOption implements SlimefunGuideOption<Boolean> {
@ -26,7 +27,9 @@ class FireworksOption implements SlimefunGuideOption<Boolean> {
@Override
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
if (Slimefun.getRegistry().isResearchFireworkEnabled()) {
SlimefunRegistry registry = Slimefun.getRegistry();
if (registry.isResearchingEnabled() && registry.isResearchFireworkEnabled()) {
boolean enabled = getSelectedOption(p, guide).orElse(true);
ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, "&bFireworks: &" + (enabled ? "aYes" : "4No"), "", "&7You can now toggle whether you", "&7will be presented with a big firework", "&7upon researching an item.", "", "&7\u21E8 &eClick to " + (enabled ? "disable" : "enable") + " your fireworks");
return Optional.of(item);

View File

@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
/**
@ -39,7 +40,9 @@ class LearningAnimationOption implements SlimefunGuideOption<Boolean> {
@Nonnull
@Override
public Optional<ItemStack> getDisplayItem(@Nonnull Player p, @Nonnull ItemStack guide) {
if (Slimefun.getRegistry().isLearningAnimationDisabled()) {
SlimefunRegistry registry = Slimefun.getRegistry();
if (!registry.isResearchingEnabled() || registry.isLearningAnimationDisabled()) {
return Optional.empty();
} else {
boolean enabled = getSelectedOption(p, guide).orElse(true);

View File

@ -7,12 +7,12 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
/**
@ -32,9 +32,8 @@ public class CargoConnectorNode extends SimpleSlimefunItem<BlockUseHandler> {
super(itemGroup, item, recipeType, recipe, recipeOutput);
}
@Nonnull
@Override
public BlockUseHandler getItemHandler() {
public @Nonnull BlockUseHandler getItemHandler() {
return e -> {
if (!e.getClickedBlock().isPresent()) {
return;
@ -44,9 +43,9 @@ public class CargoConnectorNode extends SimpleSlimefunItem<BlockUseHandler> {
Block b = e.getClickedBlock().get();
if (CargoNet.getNetworkFromLocation(b.getLocation()) != null) {
p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714"));
Slimefun.getLocalization().sendActionbarMessage(p, "machines.CARGO_NODES.connected", false);
} else {
p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718"));
Slimefun.getLocalization().sendActionbarMessage(p, "machines.CARGO_NODES.not-connected", false);
}
};
}

View File

@ -54,8 +54,7 @@ class ElevatorFloor {
*
* @return The name of this floor
*/
@Nonnull
public String getName() {
public @Nonnull String getName() {
return name;
}
@ -64,8 +63,7 @@ class ElevatorFloor {
*
* @return The {@link Location} of this floor
*/
@Nonnull
public Location getLocation() {
public @Nonnull Location getLocation() {
return location;
}

View File

@ -68,8 +68,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
addItemHandler(onPlace());
}
@Nonnull
private BlockPlaceHandler onPlace() {
private @Nonnull BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) {
@Override
@ -81,9 +80,8 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
};
}
@Nonnull
@Override
public BlockUseHandler getItemHandler() {
public @Nonnull BlockUseHandler getItemHandler() {
return e -> {
Block b = e.getClickedBlock().get();
@ -93,8 +91,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
};
}
@Nonnull
public List<ElevatorFloor> getFloors(@Nonnull Block b) {
public @Nonnull List<ElevatorFloor> getFloors(@Nonnull Block b) {
LinkedList<ElevatorFloor> floors = new LinkedList<>();
int index = 0;
@ -209,7 +206,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
@ParametersAreNonnullByDefault
public void openEditor(Player p, Block b) {
ChestMenu menu = new ChestMenu("Elevator Settings");
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.editor-title"));
menu.addItem(4, new CustomItemStack(Material.NAME_TAG, "&7Floor Name &e(Click to edit)", "", ChatColor.WHITE + ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY))));
menu.addMenuClickHandler(4, (pl, slot, item, action) -> {

View File

@ -168,6 +168,7 @@ messages:
piglin-barter: '&4You cannot barter with piglins using Slimefun items'
bee-suit-slow-fall: '&eYour Bee Wings will help you to get back to the ground safe and slow'
deprecated-item: '&4This item has been deprecated and will be removed from Slimefun soon.'
researching-is-disabled: '&cResearching has been disabled on this server. Everything is unlocked by default!'
multi-tool:
mode-change: '&b%device% mode changed to: &9%mode%'
@ -296,8 +297,9 @@ machines:
pick-a-floor: '&3- Pick a floor -'
current-floor: '&eThis is the floor you are currently on:'
click-to-teleport: '&eClick &7to teleport to this floor:'
enter-name: '&7Please enter your desired floor name into your Chat. &r(Color Codes are supported!)'
named: '&2Successfully named this floor: &r%floor%'
enter-name: '&7Please enter your desired floor name into your Chat. &f(Color Codes are supported!)'
named: '&2Successfully named this floor: &f%floor%'
editor-title: 'Configure this elevator'
TELEPORTER:
teleporting: '&3Teleporting...'
@ -317,6 +319,8 @@ machines:
CARGO_NODES:
must-be-placed: '&4Must be placed onto a chest or machine!'
connected: '&2Connected!'
not-connected: '&4Not connected!'
INDUSTRIAL_MINER:
no-fuel: '&cYour Industrial Miner ran out of fuel! Put your fuel into the chest above.'
@ -356,6 +360,8 @@ cauldron:
gps:
deathpoint: '&4Deathpoint &7%date%'
status-online: 'ONLINE'
status-offline: 'OFFLINE'
waypoint:
new: '&ePlease type in a name for your new waypoint in the chat. &7(Color Codes supported!)'
added: '&aSuccessfully added a new waypoint'