Skip to content

Commit

Permalink
Add new setting for global shop view permission, add insert after sel…
Browse files Browse the repository at this point in the history
…ected waypoint functionality
  • Loading branch information
fullwall committed May 20, 2023
1 parent 7e3f628 commit ee77512
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions main/src/main/java/net/citizensnpcs/Settings.java
Expand Up @@ -241,6 +241,9 @@ public void loadFromKey(DataKey root) {
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"),
Expand Down
5 changes: 5 additions & 0 deletions main/src/main/java/net/citizensnpcs/trait/ShopTrait.java
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -97,6 +98,10 @@ public void onRemove() {
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);
}
Expand Down
Expand Up @@ -372,12 +372,18 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}

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);

Expand Down

0 comments on commit ee77512

Please sign in to comment.