Add new setting for global shop view permission, add insert after selected waypoint functionality

This commit is contained in:
fullwall 2023-05-20 17:10:53 +08:00
parent 7e3f628b55
commit ee77512185
3 changed files with 17 additions and 3 deletions

View File

@ -241,6 +241,9 @@ public class Settings {
SELECTION_ITEM("The default item in hand to select an NPC", "npc.selection.item", "stick"),
SELECTION_MESSAGE("npc.selection.message", "Selected [[<npc>]] (ID [[<id>]])."),
SERVER_OWNS_NPCS("Whether the server owns NPCs rather than individual players", "npc.server-ownership", false),
SHOP_GLOBAL_VIEW_PERMISSION(
"The global view permission that players need to view any NPC shop. Defaults to empty (no permission required).",
"npc.shops.global-view-permission", ""),
STORAGE_FILE("storage.file", "saves.yml"),
STORAGE_TYPE("Although technically Citizens can use NBT storage, it is not well tested and YAML is recommended",
"storage.type", "yaml"),

View File

@ -24,6 +24,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.StoredShops;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.gui.CitizensInventoryClickEvent;
@ -97,6 +98,10 @@ public class ShopTrait extends Trait {
public void onRightClick(Player player) {
if (rightClickShop == null || rightClickShop.isEmpty())
return;
if (!Setting.SHOP_GLOBAL_VIEW_PERMISSION.asString().isEmpty()
&& !player.hasPermission(Setting.SHOP_GLOBAL_VIEW_PERMISSION.asString()))
return;
NPCShop shop = shops.globalShops.getOrDefault(rightClickShop, getDefaultShop());
shop.display(player);
}

View File

@ -372,12 +372,18 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider {
}
Waypoint element = new Waypoint(at);
waypoints.add(element);
int idx = waypoints.size();
if (waypoints.indexOf(selectedWaypoint) != -1) {
idx = waypoints.indexOf(selectedWaypoint);
waypoints.add(idx, element);
} else {
waypoints.add(element);
}
if (showingMarkers) {
markers.createMarker(element, element.getLocation().clone());
}
Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT, formatLoc(at),
waypoints.size());
Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT, formatLoc(at), idx);
} else if (waypoints.size() > 0 && !event.getPlayer().isSneaking()) {
event.setCancelled(true);