Groups based piston power

This commit is contained in:
Ilya 2022-02-10 19:24:28 +03:00
parent 7829f4b145
commit 358aa4e2dc
4 changed files with 32 additions and 4 deletions

View File

@ -23,6 +23,7 @@ repositories {
dependencies { dependencies {
compileOnly 'com.destroystokyo.paper:paper-api:1.12.2-R0.1-SNAPSHOT' compileOnly 'com.destroystokyo.paper:paper-api:1.12.2-R0.1-SNAPSHOT'
compileOnly 'org.bukkit:craftbukkit:1.12.2-R0.1-20190527.155144-32' compileOnly 'org.bukkit:craftbukkit:1.12.2-R0.1-20190527.155144-32'
compileOnly "com.github.MilkBowl:VaultAPI:1.7"
} }
def targetJavaVersion = 8 def targetJavaVersion = 8

View File

@ -1,15 +1,36 @@
package ru.redguy.extendedpistons; package ru.redguy.extendedpistons;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
public final class ExtendedPistons extends JavaPlugin { public final class ExtendedPistons extends JavaPlugin {
public static ExtendedPistons INSTANCE; public static ExtendedPistons INSTANCE;
public FileConfiguration conf;
public Permission permsService = null;
@Override @Override
public void onEnable() { public void onEnable() {
INSTANCE = this; INSTANCE = this;
conf = getConfig();
if(!conf.isSet("piston-move-limitations"))
conf.set("piston-move-limitations",new HashMap<String, Integer>() {{
put("default", 8);
put("vip", 12);
put("premium", 20);
}});
saveConfig();
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
permsService = rsp.getProvider();
Bukkit.getPluginManager().registerEvents(new WorldListener(), this); Bukkit.getPluginManager().registerEvents(new WorldListener(), this);
} }

View File

@ -5,6 +5,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.*; import org.bukkit.block.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -194,11 +195,14 @@ public class WorldListener implements Listener {
} }
public int findNearbyPlayerMaxBlocks(Location location) { public int findNearbyPlayerMaxBlocks(Location location) {
Optional<Player> op = (Optional<Player>) Bukkit.getOnlinePlayers().stream().min(Comparator.comparingDouble(p -> p.getLocation().distance(location))); Optional<? extends Player> op = Bukkit.getOnlinePlayers().stream().min(Comparator.comparingDouble(p -> p.getLocation().distance(location)));
if(op.isPresent()) { if(op.isPresent()) {
return 20; //TODO String[] groups = ExtendedPistons.INSTANCE.permsService.getPlayerGroups(op.get());
} else { for (String group : groups) {
return 12; if(ExtendedPistons.INSTANCE.conf.isSet("piston-move-limitations."+group)&&ExtendedPistons.INSTANCE.conf.isInt("piston-move-limitations."+group))
return ExtendedPistons.INSTANCE.conf.getInt("piston-move-limitations."+group);
}
} }
return 12;
} }
} }

View File

@ -5,3 +5,5 @@ prefix: Pis
authors: [ Redguy ] authors: [ Redguy ]
description: Plugin for very cool pistions description: Plugin for very cool pistions
website: https://redguy.ru website: https://redguy.ru
depend:
- Vault