Add dependency: LibAC
Remove compatibility with luckperms
This commit is contained in:
parent
5d024f425c
commit
00ea4681d8
20 changed files with 30 additions and 316 deletions
|
@ -7,11 +7,11 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.libzontreck.permissions.PermissionStorage;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||
import dev.zontreck.libzontreck.commands.Commands;
|
||||
import dev.zontreck.libzontreck.events.ForgeEventHandlers;
|
||||
import dev.zontreck.libzontreck.memory.VolatilePlayerStorage;
|
||||
|
@ -37,7 +37,7 @@ public class LibZontreck {
|
|||
public static final Map<String, Profile> PROFILES;
|
||||
public static MinecraftServer THE_SERVER;
|
||||
public static VolatilePlayerStorage playerStorage;
|
||||
public static boolean ALIVE;
|
||||
public static boolean ALIVE=true;
|
||||
public static final String FILESTORE = FileTreeDatastore.get();
|
||||
public static final Path BASE_CONFIG;
|
||||
public static final String PLAYER_INFO_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
||||
|
@ -92,11 +92,7 @@ public class LibZontreck {
|
|||
public void onServerStopping(final ServerStoppingEvent ev)
|
||||
{
|
||||
ALIVE=false;
|
||||
try {
|
||||
PermissionStorage.save();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
DelayedExecutorService.stop();
|
||||
|
||||
Iterator<Profile> iProfile = PROFILES.values().iterator();
|
||||
while(iProfile.hasNext())
|
||||
|
@ -111,10 +107,10 @@ public class LibZontreck {
|
|||
public static class ClientModEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent ev)
|
||||
{
|
||||
public static void onClientSetup(FMLClientSetupEvent ev) {
|
||||
LibZontreck.CURRENT_SIDE = LogicalSide.CLIENT;
|
||||
LibZontreck.ALIVE=false; // Prevents loops on the client that are meant for server tick processing
|
||||
LibZontreck.ALIVE = false; // Prevents loops on the client that are meant for server tick processing
|
||||
|
||||
|
||||
//MenuScreens.register(ModMenuTypes.CHESTGUI.get(), ChestGuiScreen::new);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,10 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
|||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PlayerHeadItem;
|
||||
|
||||
public class GetHead {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatch)
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.zontreck.libzontreck.dynamicchest;
|
|||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class ReadOnlyItemStackHandler extends ItemStackHandler
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package dev.zontreck.libzontreck.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.zontreck.libzontreck.events;
|
||||
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class ProfileUnloadedEvent extends Event
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.items.lore;
|
||||
package dev.zontreck.libzontreck.lore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
|
@ -1,11 +1,10 @@
|
|||
package dev.zontreck.libzontreck.items.lore;
|
||||
package dev.zontreck.libzontreck.lore;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.nbt.TagTypes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class LoreContainer {
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.items.lore;
|
||||
package dev.zontreck.libzontreck.lore;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.items.lore;
|
||||
package dev.zontreck.libzontreck.lore;
|
||||
|
||||
public enum LoreType {
|
||||
UNKNOWN((byte) 0x00),
|
|
@ -2,7 +2,6 @@ package dev.zontreck.libzontreck.networking.packets;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import dev.zontreck.libzontreck.networking.ModMessages;
|
||||
import dev.zontreck.libzontreck.util.BinUtil;
|
||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package dev.zontreck.libzontreck.permissions;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class Permission {
|
||||
public String permName;
|
||||
boolean isGroup(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public Permission(String name){
|
||||
|
||||
this.permName = name;
|
||||
}
|
||||
|
||||
public CompoundTag save()
|
||||
{
|
||||
CompoundTag tag=new CompoundTag();
|
||||
tag.putString("name", permName);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public Permission(CompoundTag tag)
|
||||
{
|
||||
this(tag.getString("name"));
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package dev.zontreck.libzontreck.permissions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.util.FileTreeDatastore;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermissionStorage extends FileTreeDatastore
|
||||
{
|
||||
public static final Path BASE = LibZontreck.BASE_CONFIG.resolve(
|
||||
"permissions.nbt");
|
||||
|
||||
private static final List<PermissionUser> permissionUsers;
|
||||
public static List<PermissionUser> getListOfUsers()
|
||||
{
|
||||
return Lists.newArrayList(permissionUsers);
|
||||
}
|
||||
|
||||
static{
|
||||
// Load the permission storage!
|
||||
List<PermissionUser> perms = new ArrayList<>();
|
||||
try {
|
||||
CompoundTag file = NbtIo.read(BASE.toFile());
|
||||
ListTag lst = file.getList("perms", Tag.TAG_COMPOUND);
|
||||
for (Tag tag :
|
||||
lst) {
|
||||
CompoundTag ct = (CompoundTag) tag;
|
||||
perms.add(new PermissionUser(ct));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
permissionUsers=perms;
|
||||
}
|
||||
|
||||
|
||||
public PermissionUser getUser(UUID user)
|
||||
{
|
||||
try{
|
||||
|
||||
return permissionUsers.stream()
|
||||
.filter(C->C.player.equals(user))
|
||||
.collect(Collectors.toList()).get(0);
|
||||
}catch(Exception e)
|
||||
{
|
||||
return new PermissionUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() throws IOException {
|
||||
CompoundTag ct = new CompoundTag();
|
||||
ListTag tag = new ListTag();
|
||||
for (PermissionUser user :
|
||||
permissionUsers) {
|
||||
tag.add(user.save());
|
||||
}
|
||||
|
||||
ct.put("perms", tag);
|
||||
NbtIo.write(ct, BASE.toFile());
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package dev.zontreck.libzontreck.permissions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PermissionUser {
|
||||
|
||||
public UUID player;
|
||||
public List<Permission> permissions = Lists.newArrayList();
|
||||
|
||||
public PermissionUser(Player player)
|
||||
{
|
||||
this(player.getUUID());
|
||||
}
|
||||
|
||||
public PermissionUser(UUID ID)
|
||||
{
|
||||
player=ID;
|
||||
}
|
||||
|
||||
public CompoundTag save()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putUUID("id", player);
|
||||
ListTag perms = new ListTag();
|
||||
for (Permission perm :
|
||||
permissions) {
|
||||
perms.add(perm.save());
|
||||
|
||||
}
|
||||
|
||||
tag.put("perms", perms);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public PermissionUser(CompoundTag tag)
|
||||
{
|
||||
player = tag.getUUID("id");
|
||||
|
||||
ListTag lst = tag.getList("perms", Tag.TAG_COMPOUND);
|
||||
for (Tag t :
|
||||
lst) {
|
||||
CompoundTag ct = (CompoundTag) t;
|
||||
permissions.add(new Permission(ct));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermission(String node)
|
||||
{
|
||||
return permissions.stream()
|
||||
.filter(CPRED-> CPRED.permName.equals(node))
|
||||
.count()>0;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
|
||||
|
||||
public class DelayedExecutorService {
|
||||
private static AtomicInteger COUNT = new AtomicInteger(0);
|
||||
private static final DelayedExecutorService inst;
|
||||
private static final Timer repeater;
|
||||
static{
|
||||
inst=new DelayedExecutorService();
|
||||
repeater=new Timer();
|
||||
repeater.schedule(new TimerTask(){
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
DelayedExecutorService.getInstance().onTick();
|
||||
|
||||
}
|
||||
}, 1000L, 1000L);
|
||||
}
|
||||
private DelayedExecutorService(){}
|
||||
|
||||
public static DelayedExecutorService getInstance()
|
||||
{
|
||||
return inst;
|
||||
}
|
||||
public class DelayedExecution
|
||||
{
|
||||
public DelayedExecution(Runnable run, long unix) {
|
||||
scheduled=run;
|
||||
unix_time=unix;
|
||||
}
|
||||
public Runnable scheduled;
|
||||
public long unix_time;
|
||||
}
|
||||
|
||||
public List<DelayedExecution> EXECUTORS = new ArrayList<>();
|
||||
|
||||
public void schedule(final Runnable run, int seconds)
|
||||
{
|
||||
if(!LibZontreck.ALIVE)return;
|
||||
//long unix = Instant.now().getEpochSecond()+ (seconds);
|
||||
TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
run.run();
|
||||
}
|
||||
};
|
||||
repeater.schedule(task, seconds*1000L);
|
||||
//DelayedExecution exe = new DelayedExecution(run,unix);
|
||||
//EXECUTORS.add(exe);
|
||||
}
|
||||
|
||||
private static void stopRepeatingThread()
|
||||
{
|
||||
repeater.cancel();
|
||||
}
|
||||
|
||||
public void onTick()
|
||||
{
|
||||
if(!LibZontreck.ALIVE)
|
||||
{
|
||||
LibZontreck.LOGGER.info("Tearing down delayed executor service");
|
||||
DelayedExecutorService.stopRepeatingThread();
|
||||
return;
|
||||
}
|
||||
/*Iterator<DelayedExecution> it = EXECUTORS.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
DelayedExecution e = it.next();
|
||||
if(e.unix_time < Instant.now().getEpochSecond())
|
||||
{
|
||||
it.remove();
|
||||
Thread tx = new Thread(e.scheduled);
|
||||
tx.setName("DelayedExecutorTask-"+String.valueOf(DelayedExecutorService.getNext()));
|
||||
tx.start();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public static int getNext()
|
||||
{
|
||||
return COUNT.getAndIncrement();
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
|
||||
import dev.zontreck.libzontreck.permissions.PermissionStorage;
|
||||
import dev.zontreck.libzontreck.permissions.PermissionUser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionsWatchdog implements Runnable
|
||||
{
|
||||
public List<PermissionUser> perms;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!perms.equals(PermissionStorage.getListOfUsers()))
|
||||
{
|
||||
try {
|
||||
PermissionStorage.save();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
perms = PermissionStorage.getListOfUsers();
|
||||
}
|
||||
|
||||
DelayedExecutorService.getInstance().schedule(this, 10);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.zontreck.libzontreck.vectors;
|
|||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class ChunkPos {
|
||||
public Points points;
|
||||
|
|
Reference in a new issue