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

[CI skip] Various fixes and documentation [javadocs]

This commit is contained in:
TheBusyBiscuit 2020-04-12 12:15:05 +02:00
parent 0c96323de9
commit 15ed598552
6 changed files with 65 additions and 32 deletions

View File

@ -49,6 +49,7 @@
#### Additions
* Added GEOResourceGenerationEvent
* Added AncientAltarCraftEvent
* Added SlimefunGuide-Options API
* Added ItemSettings API
* Added experimental 1.13 backwards compatibility
@ -74,6 +75,9 @@
* Fixed empty categories showing up when items inside were hidden
* Fixed ghost pages showing up when too many categories were disabled
* Fixed debug fish not showing the correct chunk timings
* Fixed heads with missing permissions placing down
* Fixed unpermitted items still showing up in the guide if researches are disabled
* Fixed unpermitted items in the book guide triggering the search function
## Release Candidate 10 (28 Mar 2020)

View File

@ -1,6 +1,5 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask;
@ -50,7 +49,7 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
public HandlerList getHandlers() {
return handlers;
}
/**
* This method returns the main altar's block {@link Block}
*
@ -72,7 +71,8 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
/**
* This method will change the item that would be dropped by the {@link AncientAltar}
*
* @param output being the {@link ItemStack} you want to change the item to.
* @param output
* being the {@link ItemStack} you want to change the item to.
*/
public void setItem(ItemStack output) {
this.output = output;

View File

@ -58,6 +58,16 @@ public class GPSNetwork {
private final ItemStack endIcon = SkullItem.fromHash("c6cac59b2aae489aa0687b5d802b2555eb14a40bd62b21eb116fa569cdb756");
private final ItemStack worldIcon = SkullItem.fromHash("c9c8881e42915a9d29bb61a16fb26d059913204d265df5b439b3d792acd56");
/**
* This method updates the status of a {@link GPSTransmitter}.
*
* @param l
* The {@link Location} of the {@link GPSTransmitter}
* @param uuid
* The {@link UUID} who the {@link GPSTransmitter} belongs to
* @param online
* Whether that {@link GPSTransmitter} is online
*/
public void updateTransmitter(Location l, UUID uuid, boolean online) {
Set<Location> set = transmitters.computeIfAbsent(uuid, id -> new HashSet<>());
@ -69,6 +79,16 @@ public class GPSNetwork {
}
}
/**
* This method calculates the GPS complexity for the given {@link UUID}.
* The complexity is determined by the Y level of each {@link GPSTransmitter}
* multiplied by the multiplier of that transmitter.
*
* @param uuid
* The {@link UUID} who to calculate it for
*
* @return The network complexity for that {@link UUID}
*/
public int getNetworkComplexity(UUID uuid) {
if (!transmitters.containsKey(uuid)) {
return 0;

View File

@ -52,14 +52,17 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
book.setTitle(SlimefunPlugin.getLocal().getMessage(p, "guide.title.main"));
for (int i = 0; i < lines.size(); i = i + 10) {
ChatComponent page = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocal().getMessage(p, "guide.title.main") + " -\n\n"));
page.setHoverEvent(new HoverEvent(ChestMenuUtils.getSearchButton(p)));
ChatComponent page = new ChatComponent("");
ChatComponent header = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocal().getMessage(p, "guide.title.main") + " -\n\n"));
header.setHoverEvent(new HoverEvent(ChestMenuUtils.getSearchButton(p)));
page.setClickEvent(new ClickEvent(guideSearch, player -> PlayerProfile.get(player, profile -> Slimefun.runSync(() -> {
header.setClickEvent(new ClickEvent(guideSearch, player -> PlayerProfile.get(player, profile -> Slimefun.runSync(() -> {
SlimefunPlugin.getLocal().sendMessage(player, "guide.search.message");
ChatInput.waitForPlayer(SlimefunPlugin.instance, player, msg -> SlimefunGuide.openSearch(profile, msg, true, true));
}, 1))));
page.append(header);
for (int j = i; j < lines.size() && j < i + 10; j++) {
page.append(lines.get(j));
}
@ -193,7 +196,10 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
List<String> lore = new ArrayList<>();
lore.add(ChatColor.DARK_RED + ChatColor.stripColor(ItemUtils.getItemName(item.getItem())));
lore.add("");
lore.addAll(SlimefunPlugin.getPermissionsService().getLore(item));
for (String line : SlimefunPlugin.getPermissionsService().getLore(item)) {
lore.add(ChatColors.color(line));
}
component.setHoverEvent(new HoverEvent(lore));
lines.add(component);

View File

@ -214,34 +214,32 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
if (Slimefun.isEnabled(p, sfitem, false)) {
Research research = sfitem.getResearch();
if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) {
if (Slimefun.hasPermission(p, sfitem, false)) {
menu.addItem(index, new CustomItem(Material.BARRIER, "&r" + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocal().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) {
if (research.canUnlock(pl)) {
if (profile.hasUnlocked(research)) {
openCategory(profile, category, page);
}
else {
unlockItem(pl, sfitem, () -> openCategory(profile, category, page));
}
if (isSurvivalMode() && !Slimefun.hasPermission(p, sfitem, false)) {
List<String> message = SlimefunPlugin.getPermissionsService().getLore(sfitem);
menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[0])));
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
index++;
}
else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) {
menu.addItem(index, new CustomItem(Material.BARRIER, "&r" + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocal().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) {
if (research.canUnlock(pl)) {
if (profile.hasUnlocked(research)) {
openCategory(profile, category, page);
}
else {
SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true);
unlockItem(pl, sfitem, () -> openCategory(profile, category, page));
}
}
return false;
});
else {
SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true);
}
}
return false;
});
index++;
}
else {
List<String> message = SlimefunPlugin.getPermissionsService().getLore(sfitem);
menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[message.size()])));
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
index++;
}
index++;
}
else {
menu.addItem(index, sfitem.getItem());

View File

@ -51,8 +51,13 @@ public class SlimefunItemListener implements Listener {
if (event.useItem() != Result.DENY) {
Optional<SlimefunItem> optional = event.getSlimefunItem();
if (optional.isPresent() && Slimefun.hasUnlocked(e.getPlayer(), optional.get(), true)) {
itemUsed = optional.get().callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event));
if (optional.isPresent()) {
if (Slimefun.hasUnlocked(e.getPlayer(), optional.get(), true)) {
itemUsed = optional.get().callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event));
}
else {
event.setUseItem(Result.DENY);
}
}
}