Compare commits
3 Commits
17eb186d2b
...
b9d4d86316
Author | SHA1 | Date |
---|---|---|
ceze88 | b9d4d86316 | |
ceze88 | 9bfcc83ba6 | |
ceze88 | 6e92c7fec9 |
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>com.craftaro</groupId>
|
<groupId>com.craftaro</groupId>
|
||||||
<artifactId>FabledSkyBlock</artifactId>
|
<artifactId>FabledSkyBlock</artifactId>
|
||||||
<version>3.0.7</version>
|
<version>3.0.8</version>
|
||||||
|
|
||||||
<name>FabledSkyBlock</name>
|
<name>FabledSkyBlock</name>
|
||||||
<description>Bring your server's SkyBlock experience to the next level with the ability to fine-tune island settings, create custom islands, view leaderboards, and much more</description>
|
<description>Bring your server's SkyBlock experience to the next level with the ability to fine-tune island settings, create custom islands, view leaderboards, and much more</description>
|
||||||
|
|
|
@ -204,13 +204,14 @@ public class Island {
|
||||||
|
|
||||||
for (BasicPermission permission : allPermissions) {
|
for (BasicPermission permission : allPermissions) {
|
||||||
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
|
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
|
||||||
.getString("Settings." + roleList.name() + "." + permission.getName()) == null) {
|
.getString("Settings." + roleList.getFriendlyName().toUpperCase(Locale.US) + "." + permission.getName()) == null) {
|
||||||
|
//save default value if not exist
|
||||||
permissions.add(
|
permissions.add(
|
||||||
new IslandPermission(permission, this.plugin.getSettings()
|
new IslandPermission(permission, this.plugin.getSettings()
|
||||||
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
|
.getBoolean("Settings." + roleList.getFriendlyName().toUpperCase(Locale.US) + "." + permission.getName(), permission.getDefaultValues().get(roleList))));
|
||||||
} else {
|
} else {
|
||||||
permissions.add(new IslandPermission(permission, settingsDataConfig.getFileConfiguration()
|
permissions.add(new IslandPermission(permission, settingsDataConfig.getFileConfiguration()
|
||||||
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
|
.getBoolean("Settings." + roleList.getFriendlyName().toUpperCase(Locale.US) + "." + permission.getName(), true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,37 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class BasicPermission {
|
public abstract class BasicPermission {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final XMaterial icon;
|
private final XMaterial icon;
|
||||||
private final PermissionType type;
|
private final PermissionType type;
|
||||||
|
|
||||||
|
//It used to write the permission's value
|
||||||
|
//to the global settings.yml which will be defaulted on all islands
|
||||||
|
private final Map<IslandRole, Boolean> defaultValues;
|
||||||
|
|
||||||
protected BasicPermission(@Nonnull String name, @Nonnull XMaterial icon, @Nonnull PermissionType type) {
|
protected BasicPermission(@Nonnull String name, @Nonnull XMaterial icon, @Nonnull PermissionType type) {
|
||||||
|
this(name, icon, type, new HashMap<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BasicPermission(@Nonnull String name, @Nonnull XMaterial icon, @Nonnull PermissionType type, Map<IslandRole, Boolean> defaultValues) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
if (defaultValues.isEmpty()) {
|
||||||
|
this.defaultValues = new HashMap<>();
|
||||||
|
this.defaultValues.put(IslandRole.VISITOR, false);
|
||||||
|
this.defaultValues.put(IslandRole.MEMBER, true);
|
||||||
|
this.defaultValues.put(IslandRole.OPERATOR, true);
|
||||||
|
this.defaultValues.put(IslandRole.COOP, true);
|
||||||
|
this.defaultValues.put(IslandRole.OWNER, true);
|
||||||
|
} else {
|
||||||
|
this.defaultValues = defaultValues;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem(Island island, IslandRole role) {
|
public ItemStack getItem(Island island, IslandRole role) {
|
||||||
|
@ -72,4 +92,8 @@ public abstract class BasicPermission {
|
||||||
public PermissionType getType() {
|
public PermissionType getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<IslandRole, Boolean> getDefaultValues() {
|
||||||
|
return defaultValues;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.craftaro.skyblock.permission;
|
package com.craftaro.skyblock.permission;
|
||||||
|
|
||||||
|
import com.craftaro.skyblock.island.IslandRole;
|
||||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||||
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
|
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
|
||||||
import com.craftaro.skyblock.SkyBlock;
|
import com.craftaro.skyblock.SkyBlock;
|
||||||
|
@ -34,11 +35,17 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class ListeningPermission extends BasicPermission {
|
public abstract class ListeningPermission extends BasicPermission {
|
||||||
protected ListeningPermission(String name, XMaterial icon, PermissionType type) {
|
protected ListeningPermission(String name, XMaterial icon, PermissionType type) {
|
||||||
super(name, icon, type);
|
super(name, icon, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ListeningPermission(String name, XMaterial icon, PermissionType type, Map<IslandRole, Boolean> defaultValues) {
|
||||||
|
super(name, icon, type, defaultValues);
|
||||||
|
}
|
||||||
|
|
||||||
public void onInteract(PlayerInteractEvent event) {
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.craftaro.skyblock.permission;
|
package com.craftaro.skyblock.permission;
|
||||||
|
|
||||||
|
import com.craftaro.core.compatibility.ServerVersion;
|
||||||
import com.craftaro.skyblock.SkyBlock;
|
import com.craftaro.skyblock.SkyBlock;
|
||||||
import com.craftaro.skyblock.config.FileManager;
|
import com.craftaro.skyblock.config.FileManager;
|
||||||
import com.craftaro.skyblock.island.Island;
|
import com.craftaro.skyblock.island.Island;
|
||||||
|
@ -141,6 +142,10 @@ public class PermissionManager {
|
||||||
registerPermission(new HungerPermission(plugin));
|
registerPermission(new HungerPermission(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_20)) {
|
||||||
|
registerPermission(new SignEditPermission(plugin));
|
||||||
|
}
|
||||||
|
|
||||||
this.registeredHandlers = this.registeredHandlers.stream()
|
this.registeredHandlers = this.registeredHandlers.stream()
|
||||||
.sorted(Comparator.comparingInt(h -> h.getHandler().getAnnotation(PermissionHandler.class).priority().ordinal()))
|
.sorted(Comparator.comparingInt(h -> h.getHandler().getAnnotation(PermissionHandler.class).priority().ordinal()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -153,13 +158,16 @@ public class PermissionManager {
|
||||||
switch (permission.getType()) {
|
switch (permission.getType()) {
|
||||||
case GENERIC:
|
case GENERIC:
|
||||||
if (settingsConfigLoad.getString("Settings.Visitor." + permission.getName()) == null) {
|
if (settingsConfigLoad.getString("Settings.Visitor." + permission.getName()) == null) {
|
||||||
settingsConfigLoad.set("Settings.Visitor." + permission.getName(), true);
|
settingsConfigLoad.set("Settings.Visitor." + permission.getName(), permission.getDefaultValues().get(IslandRole.VISITOR));
|
||||||
|
if (permission.getName().equals("EditSign")) {
|
||||||
|
System.err.println("Default EditSign Visitor permission set to: " + permission.getDefaultValues().get(IslandRole.VISITOR));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (settingsConfigLoad.getString("Settings.Member." + permission.getName()) == null) {
|
if (settingsConfigLoad.getString("Settings.Member." + permission.getName()) == null) {
|
||||||
settingsConfigLoad.set("Settings.Member." + permission.getName(), true);
|
settingsConfigLoad.set("Settings.Member." + permission.getName(), permission.getDefaultValues().get(IslandRole.MEMBER));
|
||||||
}
|
}
|
||||||
if (settingsConfigLoad.getString("Settings.Coop." + permission.getName()) == null) {
|
if (settingsConfigLoad.getString("Settings.Coop." + permission.getName()) == null) {
|
||||||
settingsConfigLoad.set("Settings.Coop." + permission.getName(), true);
|
settingsConfigLoad.set("Settings.Coop." + permission.getName(), permission.getDefaultValues().get(IslandRole.COOP));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPERATOR:
|
case OPERATOR:
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.craftaro.skyblock.permission.permissions.listening;
|
||||||
|
|
||||||
|
import com.craftaro.skyblock.SkyBlock;
|
||||||
|
import com.craftaro.skyblock.island.IslandRole;
|
||||||
|
import com.craftaro.skyblock.permission.ListeningPermission;
|
||||||
|
import com.craftaro.skyblock.permission.PermissionHandler;
|
||||||
|
import com.craftaro.skyblock.permission.PermissionType;
|
||||||
|
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SignEditPermission extends ListeningPermission {
|
||||||
|
|
||||||
|
private final SkyBlock plugin;
|
||||||
|
|
||||||
|
public SignEditPermission(SkyBlock plugin) {
|
||||||
|
super("EditSign", XMaterial.OAK_SIGN, PermissionType.GENERIC, new HashMap<IslandRole, Boolean>() {{
|
||||||
|
put(IslandRole.VISITOR, false);
|
||||||
|
put(IslandRole.MEMBER, true);
|
||||||
|
put(IslandRole.OPERATOR, true);
|
||||||
|
put(IslandRole.COOP, true);
|
||||||
|
put(IslandRole.OWNER, true);
|
||||||
|
}});
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PermissionHandler
|
||||||
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
|
if (event.getClickedBlock() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (event.getClickedBlock().getType().name().contains("SIGN")) {
|
||||||
|
cancelAndMessage(event, player, this.plugin, this.plugin.getMessageManager());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue