Kajetan Johannes Hammerle 7 лет назад
Родитель
Сommit
a41b6fea6b

+ 0 - 5
src/main/java/me/km/CommonProxy.java

@@ -3,18 +3,13 @@ package me.km;
 import me.km.blocks.BlockEvents;
 import me.km.entities.ModEntities;
 import me.km.events.CustomEventCaller;
-import me.km.playerbank.ModDedicatedPlayerList;
 import net.minecraft.client.model.ModelBiped;
 import net.minecraft.client.renderer.entity.Render;
 import net.minecraft.entity.Entity;
 import net.minecraft.item.Item;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.server.dedicated.DedicatedServer;
 import net.minecraft.util.ResourceLocation;
 import net.minecraftforge.common.MinecraftForge;
 import net.minecraftforge.fluids.IFluidBlock;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
 
 public class CommonProxy 
 {

+ 1 - 1
src/main/java/me/km/KajetansMod.java

@@ -69,7 +69,7 @@ public class KajetansMod
 
     public static final String MODID = "km";
     public static final String NAME = "Kajetans Mod";
-    public static final String VERSION = "0.0.22";
+    public static final String VERSION = "0.0.23";
 
     @Mod.Instance(MODID)
     public static KajetansMod instance;

+ 108 - 0
src/main/java/me/km/chatchannel/ChatChannel.java

@@ -0,0 +1,108 @@
+package me.km.chatchannel;
+
+import java.util.HashSet;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import me.km.KajetansMod;
+import me.km.permissions.Permissions;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.text.TextComponentString;
+
+public class ChatChannel 
+{
+    // -------------------------------------------------------------------------
+    // static stuff
+    // -------------------------------------------------------------------------
+    
+    public static ChatChannel getDevChannel()
+    {
+        return DEV_CHANNEL;
+    };
+    
+    private final static ChatChannel DEV_CHANNEL = new ChatChannel("Dev", TextColor.LIGHT_PURPLE, 
+            (cc, s) -> 
+            {
+                TextComponentString text = new TextComponentString(s);
+                cc.receivers.forEach(p -> p.sendMessage(text));
+            },
+            (cc, p) -> 
+            {
+                if(KajetansMod.perms.hasPermission(p, Permissions.SCRIPT_ERROR))
+                {
+                    cc.addPlayer(p);
+                }
+            }, 
+            (cc, p) -> 
+            {
+                cc.removePlayer(p);
+            });   
+    
+    public static void onPlayerLogIn(EntityPlayer p)
+    {
+        DEV_CHANNEL.onLogin.accept(DEV_CHANNEL, p);
+    }
+    
+    public static void onPlayerLogOut(EntityPlayer p)
+    {
+        DEV_CHANNEL.onLogout.accept(DEV_CHANNEL, p);
+    }
+    
+    // -------------------------------------------------------------------------
+    // chat channels
+    // -------------------------------------------------------------------------
+    
+    private final HashSet<EntityPlayer> receivers;
+    private final String prefix;
+    private final String list;
+    private final BiConsumer<ChatChannel, String> onSend;
+    private final BiConsumer<ChatChannel, EntityPlayer> onLogin;
+    private final BiConsumer<ChatChannel, EntityPlayer> onLogout;
+    
+    private ChatChannel(String name, TextColor tc,
+            BiConsumer<ChatChannel, String> onSend,
+            BiConsumer<ChatChannel, EntityPlayer> onLogin,
+            BiConsumer<ChatChannel, EntityPlayer> onLogout)
+    {
+        receivers = new HashSet<>();
+        this.prefix = "[" + tc + name + TextColor.RESET + "] ";
+        this.list = tc + " - ";
+        this.onSend = onSend;
+        this.onLogin = onLogin;
+        this.onLogout = onLogout;
+    }
+    
+    public void addPlayer(EntityPlayer p)
+    {
+        receivers.add(p);
+    }
+    
+    public void removePlayer(EntityPlayer p)
+    {
+        receivers.remove(p);
+    }
+    
+    public void send(String msg)
+    {
+        onSend.accept(this, prefix + " " + msg);
+    }
+    
+    public void sendWarning(String msg)
+    {
+        onSend.accept(this, prefix + " " + TextColor.RED + msg);
+    }
+    
+    public void sendList(String msg)
+    {
+        onSend.accept(this, list + TextColor.RESET + msg);
+    }
+    
+    public void sendList(String msg, String msg2)
+    {
+        onSend.accept(this, list + msg + TextColor.RESET + " " + msg2);
+    }
+    
+    public void forEach(Consumer<EntityPlayer> c)
+    {
+        receivers.forEach(c);
+    }
+}

+ 65 - 0
src/main/java/me/km/chatchannel/TextColor.java

@@ -0,0 +1,65 @@
+package me.km.chatchannel;
+
+import java.util.regex.Pattern;
+
+public enum TextColor
+{
+    // vanilla stuff
+    BLACK('0'),
+    DARK_BLUE('1'),
+    DARK_GREEN('2'),
+    DARK_AQUA('3'),
+    DARK_RED('4'),
+    DARK_PURPLE('5'),
+    GOLD('6'),
+    GRAY('7'),
+    DARK_GRAY('8'),
+    BLUE('9'),
+    GREEN('a'),
+    AQUA('b'),
+    RED('c'),
+    LIGHT_PURPLE('d'),
+    YELLOW('e'),
+    WHITE('f'),
+    OBFUSCATED('k'),
+    BOLD('l'),
+    STRIKETHROUGH('m'),
+    UNDERLINE('n'),
+    ITALIC('o'),
+    RESET('r'),
+    // http://chir.ag/projects/name-that-color/
+    // new colors
+    DARK_BROWN('g'),
+    LIGHT_BROWN('h'),
+    MIDNIGHT_BLUE('i'),
+    BAHAMA_BLUE('j'),
+    LIMEADE('p'),
+    PISTACHIO('q'),
+    AZURE_RADIANCE('s'),
+    MALIBU('t'),
+    OREGON('u'),
+    TENN('v'),
+    BUDDHA_GOLD('w'),
+    SUPERNOVA('x'),
+    POMPADOUR('y'),
+    ELECTRIC_VIOLET('z');
+ 
+    private static final Pattern FORMATTING_CODE_PATTERN = Pattern.compile("(?i)\u00a7[0-9A-Za-z]");
+    private final String pattern;
+
+    private TextColor(char c)
+    {
+        this.pattern = "§" + c;
+    }
+
+    @Override
+    public String toString()
+    {
+        return pattern;
+    }
+
+    public static String getTextWithoutFormattingCodes(String text)
+    {
+        return FORMATTING_CODE_PATTERN.matcher(text).replaceAll("");
+    }
+}

+ 4 - 2
src/main/java/me/km/chatmanager/CommandColor.java

@@ -20,10 +20,12 @@ public class CommandColor extends ModuleCommand
     public boolean execute(ICommandSender cs, String[] arg) 
     {
         Module m = this.getModule();
-        m.send(cs, "§9Verfügbare Farbcodes:");
+        m.send(cs, "Verfügbare Farbcodes:");
         m.send(cs, "  §0&0  §1&1  §2&2  §3&3  §4&4  §5&5  §6&6  §7&7");
         m.send(cs, "  §8&8  §9&9  §a&a  §b&b  §c&c  §d&d  §e&e  §f&f");
-        m.send(cs, "§9Sonstiges:");
+        m.send(cs, "  §g&g  §i&i  §p&p  §s&s  §u&u  §w&w  §y&y");
+        m.send(cs, "  §h&h  §j&j  §q&q  §t&t  §v&v  §x&x  §z&z");
+        m.send(cs, "Sonstiges:");
         m.send(cs, "  §l&l (fett)");
         m.send(cs, "  §m&m (durchgestrichen)");
         m.send(cs, "  §n&n (unterstrichen)");

+ 7 - 2
src/main/java/me/km/effects/passive/TrapEffects.java

@@ -27,8 +27,10 @@ public class TrapEffects
                             {
                                 p.attackEntityFrom(DamageSource.GENERIC, 6);
                                 EffectUtils.addPotionTo(p, MobEffects.SLOWNESS, 200, 1);
+                                return true;
                             }
-                        }, l.copyAdd(x, 0, z), l.copyAdd(x + 1, 1, z + 1), -1, -1, id));
+                            return false;
+                        }, l.copyAdd(x, 0, z), l.copyAdd(x + 1, 1, z + 1), 10, -1, id));
             }
         }
     }
@@ -60,8 +62,10 @@ public class TrapEffects
                             }
                         }
                         changer.run(120);
+                        return true;
                     }
-                }, l, l.copyAdd(1, 1, 1), -1, -1, id));
+                    return false;
+                }, l, l.copyAdd(1, 1, 1), 10, -1, id));
     }
     
     public static void addVineTrap(Location l, int id, int livingTime)
@@ -73,6 +77,7 @@ public class TrapEffects
                     {
                         EffectUtils.addPotionTo(p, MobEffects.POISON, 60, 2);
                     }
+                    return false;
                 }, l, l.copyAdd(2.8, 1, 2.8), 10, livingTime, id));
     }
 }

+ 15 - 0
src/main/java/me/km/events/CustomEventCaller.java

@@ -1,9 +1,12 @@
 package me.km.events;
 
 import java.util.ArrayList;
+import java.util.ConcurrentModificationException;
 import java.util.HashMap;
 import java.util.LinkedList;
+import me.hammerle.snuviscript.code.Script;
 import me.km.KajetansMod;
+import me.km.chatchannel.ChatChannel;
 import me.km.utils.ReflectionUtils;
 import net.minecraft.entity.Entity;
 import net.minecraft.entity.player.EntityPlayer;
@@ -31,6 +34,18 @@ public class CustomEventCaller
         return idCounter;
     }
     
+    public static void removeScriptData(Script sc)
+    {
+        try
+        {
+            MOVE_DATA.entrySet().removeIf(e -> e.getValue().isSameScript(sc));
+        }
+        catch(ConcurrentModificationException ex)
+        {
+            ChatChannel.getDevChannel().sendWarning("Fehler beim Entfernen der Move-Events von '" + sc.getName() + "'");
+        }
+    }
+    
     public static void removeMoveData(int id)
     {
         REMOVE_QUEUE.add(id);

+ 16 - 9
src/main/java/me/km/events/PlayerMoveData.java

@@ -1,6 +1,6 @@
 package me.km.events;
 
-import java.util.function.BiConsumer;
+import java.util.function.BiPredicate;
 import me.hammerle.snuviscript.code.Script;
 import me.km.KajetansMod;
 import me.km.api.Location;
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
 public class PlayerMoveData 
 {
     private final Script sc;
-    private final BiConsumer<EntityPlayerMP, Object> c;
+    private final BiPredicate<EntityPlayerMP, Object> c;
     private final int coolDown;
     private int ticks;
     private int livingTime;
@@ -26,7 +26,7 @@ public class PlayerMoveData
     private final double maxY;
     private final double maxZ;
     
-    private PlayerMoveData(Script sc, BiConsumer<EntityPlayerMP, Object> c, Location l1, Location l2, int cooldown, int livingTime, Object data)
+    private PlayerMoveData(Script sc, BiPredicate<EntityPlayerMP, Object> c, Location l1, Location l2, int cooldown, int livingTime, Object data)
     {
         this.sc = sc;
         this.c = c;
@@ -41,10 +41,9 @@ public class PlayerMoveData
         this.maxY = Math.max(l1.getY(), l2.getY());
         this.maxZ = Math.max(l1.getZ(), l2.getZ());
         this.data = data;
-        
-        System.out.println("X DATA FROM " + minX +" TO " + maxX);
-        System.out.println("Y DATA FROM " + minY +" TO " + maxY);
-        System.out.println("Z DATA FROM " + minZ +" TO " + maxZ);
+        //System.out.println("X DATA FROM " + minX +" TO " + maxX);
+        //System.out.println("Y DATA FROM " + minY +" TO " + maxY);
+        //System.out.println("Z DATA FROM " + minZ +" TO " + maxZ);
     }
     
     public PlayerMoveData(Script sc, Location l1, Location l2, int cooldown, int livingTime)
@@ -52,11 +51,16 @@ public class PlayerMoveData
         this(sc, null, l1, l2, cooldown, livingTime, null);
     }
     
-    public PlayerMoveData(BiConsumer<EntityPlayerMP, Object> c, Location l1, Location l2, int cooldown, int livingTime, Object data)
+    public PlayerMoveData(BiPredicate<EntityPlayerMP, Object> c, Location l1, Location l2, int cooldown, int livingTime, Object data)
     {
         this(null, c, l1, l2, cooldown, livingTime, data);
     }
     
+    public boolean isSameScript(Script sc)
+    {
+        return this.sc == sc;
+    }
+    
     public Object getData()
     {
         return data;
@@ -95,7 +99,10 @@ public class PlayerMoveData
         }
         if(c != null)
         {
-            c.accept(p, data);
+            if(c.test(p, data))
+            {
+                return true;
+            }
         }
         return coolDown == -1;
     }

+ 7 - 7
src/main/java/me/km/permissions/Permissions.java

@@ -107,13 +107,13 @@ public class Permissions
 
     // Plots
     public final static String PLOT = "plot"; 
-    public final static String PLOT_CREATE = "plotcreate";
-    public final static String PLOT_INFO = "plotinfo"; 
-    public final static String PLOT_TAG = "plottag"; 
-    public final static String PLOT_SHARE = "plotshare"; 
-    public final static String PLOT_SIGN = "plotsign"; 
-    public final static String PLOT_BYPASS = "plotbypass";
-    public final static String PLOT_MARK = "plotmark"; 
+    public final static String PLOT_CREATE = "plot.create";
+    public final static String PLOT_INFO = "plot.info"; 
+    public final static String PLOT_TAG = "plot.tag"; 
+    public final static String PLOT_SHARE = "plot.share"; 
+    public final static String PLOT_SIGN = "plot.sign"; 
+    public final static String PLOT_BYPASS = "plot.bypass";
+    public final static String PLOT_MARK = "plot.mark"; 
 
     // Scrolls
     public final static String SCROLL = "scroll"; 

+ 0 - 339
src/main/java/me/km/playerbank/ModDedicatedPlayerList.java

@@ -1,339 +0,0 @@
-package me.km.playerbank;
-
-import com.mojang.authlib.GameProfile;
-import io.netty.buffer.Unpooled;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import me.km.KajetansMod;
-import me.km.dimensions.ModDimensions;
-//import me.km.events.PlayerJoinMessageEvent;
-//import me.km.events.PlayerRespawnAtEvent;
-import me.km.utils.ReflectionUtils;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.NetHandlerPlayServer;
-import net.minecraft.network.NetworkManager;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.server.SPacketChangeGameState;
-import net.minecraft.network.play.server.SPacketCustomPayload;
-import net.minecraft.network.play.server.SPacketEntityEffect;
-import net.minecraft.network.play.server.SPacketHeldItemChange;
-import net.minecraft.network.play.server.SPacketJoinGame;
-import net.minecraft.network.play.server.SPacketPlayerAbilities;
-import net.minecraft.network.play.server.SPacketRespawn;
-import net.minecraft.network.play.server.SPacketServerDifficulty;
-import net.minecraft.network.play.server.SPacketSetExperience;
-import net.minecraft.network.play.server.SPacketSpawnPosition;
-import net.minecraft.scoreboard.ServerScoreboard;
-import net.minecraft.server.dedicated.DedicatedPlayerList;
-import net.minecraft.server.dedicated.DedicatedServer;
-import net.minecraft.server.management.DemoPlayerInteractionManager;
-import net.minecraft.server.management.PlayerInteractionManager;
-import net.minecraft.server.management.PlayerProfileCache;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3d;
-import net.minecraft.util.text.TextComponentString;
-import net.minecraft.world.GameRules;
-import net.minecraft.world.World;
-import net.minecraft.world.WorldServer;
-import net.minecraft.world.chunk.storage.AnvilChunkLoader;
-import net.minecraft.world.storage.WorldInfo;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-@SideOnly(Side.SERVER)
-public class ModDedicatedPlayerList //extends DedicatedPlayerList
-{
-    /*private final DedicatedServer mcServer;
-    private static final Logger LOG = LogManager.getLogger();
-    private final List<EntityPlayerMP> playerEntityList;
-    private final Map<UUID, EntityPlayerMP> uuidToPlayerMap;
-    
-    public ModDedicatedPlayerList(DedicatedServer server) 
-    {
-        super(server);
-        this.mcServer = server;
-        this.playerEntityList = super.getPlayers();
-        this.uuidToPlayerMap = ReflectionUtils.getUuidToPlayerMap(this);
-    }
-    
-    // copied from net.minecraft.server.management.PlayerList
-    private void setPlayerGameTypeBasedOnOther(EntityPlayerMP target, EntityPlayerMP source, World worldIn)
-    {
-        if (source != null)
-        {
-            target.interactionManager.setGameType(source.interactionManager.getGameType());
-        }
-        target.interactionManager.initializeGameType(worldIn.getWorldInfo().getGameType());
-    }
-    
-    // copied from net.minecraft.server.management.PlayerList
-    @Override
-    public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP p, NetHandlerPlayServer nethandlerplayserver)
-    {
-        // get name for old / new name comparing
-        GameProfile gameprofile = p.getGameProfile();
-        PlayerProfileCache cache = this.mcServer.getPlayerProfileCache();
-        GameProfile gameprofile1 = cache.getProfileByUUID(gameprofile.getId());
-        String playerName = gameprofile1 == null ? gameprofile.getName() : gameprofile1.getName();
-        cache.addEntry(gameprofile);
-        
-        // read data
-        NBTTagCompound nbttagcompound = this.readPlayerDataFromFile(p);
-        
-        WorldServer playerWorld = this.mcServer.getWorld(p.dimension);
-        if(playerWorld == null)
-        {
-            p.dimension = 0;
-            playerWorld = this.mcServer.getWorld(0);
-            BlockPos spawnPoint = playerWorld.provider.getRandomizedSpawnPoint();
-            p.setPosition(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
-        }
-        p.setWorld(playerWorld);
-
-        p.interactionManager.setWorld(playerWorld);
-        
-        String s = "local";
-        if(netManager.getRemoteAddress() != null)
-        {
-            s = netManager.getRemoteAddress().toString();
-        }
-
-        LOG.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[] {p.getName(), s, p.getEntityId(), p.posX, p.posY, p.posZ});
-        WorldInfo worldinfo = playerWorld.getWorldInfo();
-        this.setPlayerGameTypeBasedOnOther(p, null, playerWorld);
-        p.connection = nethandlerplayserver;
-        // send custom loaded dimensions to the player
-        ModDimensions.sendNotificationsForDimensions(p);
-        // End
-        nethandlerplayserver.sendPacket(new SPacketJoinGame(p.getEntityId(), p.interactionManager.getGameType(), worldinfo.isHardcoreModeEnabled(), p.dimension, playerWorld.getDifficulty(), this.getMaxPlayers(), worldinfo.getTerrainType(), playerWorld.getGameRules().getBoolean("reducedDebugInfo")));
-        nethandlerplayserver.sendPacket(new SPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(this.getServerInstance().getServerModName())));
-        nethandlerplayserver.sendPacket(new SPacketServerDifficulty(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
-        nethandlerplayserver.sendPacket(new SPacketPlayerAbilities(p.capabilities));
-        nethandlerplayserver.sendPacket(new SPacketHeldItemChange(p.inventory.currentItem));
-        this.updatePermissionLevel(p);
-        p.getStatFile().markAllDirty();
-        p.getRecipeBook().init(p);
-        this.sendScoreboard((ServerScoreboard) playerWorld.getScoreboard(), p);
-        this.mcServer.refreshStatusNextTick();
-        // Custom Join Message - Start
-        //TextComponentTranslation textcomponenttranslation;
-        
-        PlayerJoinMessageEvent event;
-        if (p.getName().equalsIgnoreCase(playerName))
-        {
-            //textcomponenttranslation = new TextComponentTranslation("multiplayer.player.joined", new Object[] {playerIn.getDisplayName()});
-            event = new PlayerJoinMessageEvent(p, false, "No message was set.");
-        }
-        else
-        {
-            //textcomponenttranslation = new TextComponentTranslation("multiplayer.player.joined.renamed", new Object[] {playerIn.getDisplayName(), s});
-            event = new PlayerJoinMessageEvent(p, true, "No message was set.");
-        }
-
-        //textcomponenttranslation.getStyle().setColor(TextFormatting.YELLOW);
-        //this.sendMessage(textcomponenttranslation);
-        if(!MinecraftForge.EVENT_BUS.post(event))
-        {
-            KajetansMod.scheduler.scheduleTask(() -> this.sendMessage(new TextComponentString(event.getMessage())), 2);
-        }
-        // Custom Join Message - End
-        this.playerLoggedIn(p);
-        nethandlerplayserver.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
-        this.updateTimeAndWeatherForPlayer(p, playerWorld);
-
-        if (!this.mcServer.getResourcePackUrl().isEmpty())
-        {
-            p.loadResourcePack(this.mcServer.getResourcePackUrl(), this.mcServer.getResourcePackHash());
-        }
-
-        p.getActivePotionEffects().stream().forEach((potioneffect) -> 
-        {
-            nethandlerplayserver.sendPacket(new SPacketEntityEffect(p.getEntityId(), potioneffect));
-        });
-
-        if (nbttagcompound != null && nbttagcompound.hasKey("RootVehicle", 10))
-        {
-            NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("RootVehicle");
-            Entity entity1 = AnvilChunkLoader.readWorldEntity(nbttagcompound1.getCompoundTag("Entity"), playerWorld, true);
-
-            if (entity1 != null)
-            {
-                UUID uuid = nbttagcompound1.getUniqueId("Attach");
-
-                if (entity1.getUniqueID().equals(uuid))
-                {
-                    p.startRiding(entity1, true);
-                }
-                else
-                {
-                    for (Entity entity : entity1.getRecursivePassengers())
-                    {
-                        if (entity.getUniqueID().equals(uuid))
-                        {
-                            p.startRiding(entity, true);
-                            break;
-                        }
-                    }
-                }
-
-                if (!p.isRiding())
-                {
-                    LOG.warn("Couldn\'t reattach entity to player");
-                    playerWorld.removeEntityDangerously(entity1);
-
-                    for(Entity entity2 : entity1.getRecursivePassengers())
-                    {
-                        playerWorld.removeEntityDangerously(entity2);
-                    }
-                }
-            }
-        }
-
-        p.addSelfToInternalCraftingInventory();
-
-        net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedIn(p);
-    }
-    
-    // copied from net.minecraft.server.management.PlayerList
-    @Override
-    public EntityPlayerMP recreatePlayerEntity(EntityPlayerMP p, int dim, boolean conqueredEnd)
-    {
-        dim = p.dimension;
-        WorldServer w = mcServer.getWorld(dim);
-        if(w == null)
-        {
-            dim = p.getSpawnDimension();
-        }
-        else if(!w.provider.canRespawnHere())
-        {
-            dim = w.provider.getRespawnDimension(p);
-        }
-        if(mcServer.getWorld(dim) == null)
-        {
-            dim = 0;
-        }
-
-        WorldServer pw = p.getServerWorld();
-        pw.getEntityTracker().removePlayerFromTrackers(p);
-        pw.getEntityTracker().untrack(p);
-        pw.getPlayerChunkMap().removePlayer(p);
-        this.playerEntityList.remove(p);
-        pw.removeEntityDangerously(p);
-        
-        // start of event handling
-        // determine would-be spawn
-        w = mcServer.getWorld(dim);
-        p.dimension = dim;
-
-        PlayerInteractionManager pManager;
-        // keep this demo shit for fucks sake
-        if(this.mcServer.isDemo())
-        {
-            pManager = new DemoPlayerInteractionManager(w);
-        }
-        else
-        {
-            pManager = new PlayerInteractionManager(w);
-        }
-        EntityPlayerMP newP = new EntityPlayerMP(this.mcServer, w, p.getGameProfile(), pManager);
-        newP.connection = p.connection;
-        newP.setEntityId(p.getEntityId());
-        newP.setCommandStats(p);
-        newP.setPrimaryHand(p.getPrimaryHand());
-        newP.dimension = dim;
-        
-        boolean spawnInBed = false;
-        boolean errorIfNoForce = false;
-        PlayerRespawnAtEvent event;
-        
-        BlockPos bed = p.getBedLocation(dim);
-        if(bed != null)
-        {
-            BlockPos validBed = EntityPlayer.getBedSpawnLocation(w, bed, p.isSpawnForced(dim));
-           if (validBed != null)
-            {
-                spawnInBed = true;
-                event = new PlayerRespawnAtEvent(newP, w, validBed.getX() + 0.5f, validBed.getY() + 0.1f, validBed.getZ() + 0.5f);
-            }
-            else
-            {
-                errorIfNoForce = true;
-                event = new PlayerRespawnAtEvent(newP, w, newP.posX, newP.posY, newP.posZ);
-            }
-        }
-        else
-        {
-            event = new PlayerRespawnAtEvent(newP, w, newP.posX, newP.posY, newP.posZ);
-        }
-        MinecraftForge.EVENT_BUS.post(event);
-        Vec3d v = event.getRespawnLoc();
-        // only change when there is an actual change       
-        if(event.isForced())
-        {
-            w = event.getWorld();
-            newP.world = w;
-            newP.dimension = w.provider.getDimension();
-            p.dimension = newP.dimension;
-            newP.setPosition(v.x, v.y, v.z);
-        }
-        else
-        {
-            if(spawnInBed)
-            {
-                newP.setLocationAndAngles(v.x, v.y, v.z, 0, 0);
-                newP.setSpawnPoint(bed, p.isSpawnForced(dim));
-            }
-            else if(errorIfNoForce)
-            {
-                newP.connection.sendPacket(new SPacketChangeGameState(0, 0));
-            }
-        }
-        
-        if(event.isInventoryKeepingForced() && !conqueredEnd)
-        {
-            GameRules rules = w.getGameRules();
-            boolean keep = rules.getBoolean("keepInventory");
-            rules.setOrCreateGameRule("keepInventory", "true");
-            newP.copyFrom(p, conqueredEnd);
-            rules.setOrCreateGameRule("keepInventory", String.valueOf(keep));
-        }
-        else
-        {
-            newP.copyFrom(p, conqueredEnd);
-        }
-
-        // end of event handling
-        
-        p.getTags().stream().forEach(s -> newP.addTag(s));
-        this.setPlayerGameTypeBasedOnOther(newP, p, w);
-        
-        w.getChunkProvider().provideChunk((int) newP.posX >> 4, (int) newP.posZ >> 4);
-
-        while(!w.getCollisionBoxes(newP, newP.getEntityBoundingBox()).isEmpty() && newP.posY < 256.0D)
-        {
-            newP.setPosition(newP.posX, newP.posY + 1.0D, newP.posZ);
-        }
-
-        newP.connection.sendPacket(new SPacketRespawn(newP.dimension, newP.world.getDifficulty(), w.getWorldInfo().getTerrainType(), newP.interactionManager.getGameType()));
-        newP.connection.setPlayerLocation(newP.posX, newP.posY, newP.posZ, newP.rotationYaw, newP.rotationPitch);
-        newP.connection.sendPacket(new SPacketSpawnPosition(w.getSpawnPoint()));
-        newP.connection.sendPacket(new SPacketSetExperience(newP.experience, newP.experienceTotal, newP.experienceLevel));
-        this.updateTimeAndWeatherForPlayer(newP, w);
-        this.updatePermissionLevel(newP);
-        w.getPlayerChunkMap().addPlayer(newP);
-        w.spawnEntity(newP);
-        this.playerEntityList.add(newP);
-        this.uuidToPlayerMap.put(newP.getUniqueID(), newP);
-        newP.addSelfToInternalCraftingInventory();
-        newP.setHealth(newP.getHealth());
-        net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerRespawnEvent(newP, conqueredEnd);
-        return newP;
-    }*/
-}

+ 5 - 0
src/main/java/me/km/playerbank/PlayerLogInOut.java

@@ -5,6 +5,7 @@ import me.km.KajetansMod;
 import me.km.api.Module;
 import me.km.api.ModuleListener;
 import me.km.api.Utils;
+import me.km.chatchannel.ChatChannel;
 import me.km.commands.CommandTeleportAccept;
 import me.km.dimensions.ModDimensions;
 import net.minecraft.entity.player.EntityPlayer;
@@ -52,6 +53,8 @@ public class PlayerLogInOut extends ModuleListener
                 pb.changeName(p);
             }
         }      
+        
+        ChatChannel.onPlayerLogIn(p);
     }
     
     @SubscribeEvent(priority = EventPriority.LOW)
@@ -60,6 +63,8 @@ public class PlayerLogInOut extends ModuleListener
         EntityPlayer p = e.player;
         KajetansMod.generalCommands.getCommand(CommandTeleportAccept.class).tpaccept.remove(p.getUniqueID());
         KajetansMod.scoreboard.removeScoreboard(p.getUniqueID());
+        
+        ChatChannel.onPlayerLogOut(p);
     }
     
     @SubscribeEvent

+ 1 - 1
src/main/java/me/km/snuviscript/CommandScript.java

@@ -233,7 +233,7 @@ public class CommandScript extends ModuleCommand
                     m.send(cs, "Folgende Scripts sind aktiv:");
                     scripts.forEach(sc ->
                     {
-                        m.sendHelpListElement(cs, sc.getName(), "(" + sc.getId() + ")");
+                        m.sendHelpListElement(cs, sc.getSimpleName(), "(" + sc.getId() + ")");
                         KajetansMod.scripts.getPlayerList(sc.getId()).forEach(p -> m.sendListElement(cs, p.getName()));
                     });
                     return true;

+ 2 - 3
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -18,6 +18,7 @@ import me.hammerle.snuviscript.math.Fraction;
 import me.km.api.Location;
 import me.km.api.TitleAPI;
 import me.km.api.Utils;
+import me.km.chatchannel.ChatChannel;
 import me.km.commands.CommandSilent;
 import me.km.dimensions.ModDimensions;
 import me.km.effects.EffectUtils;
@@ -1805,9 +1806,7 @@ public class MinecraftFunctions
                     KajetansMod.server.getPlayerList().getPlayers().forEach(p -> c.accept(p));
                     break;
                 case "dev":
-                    // TODO - when chat channels are done
-                    // doing this until its finished
-                    KajetansMod.server.getPlayerList().getPlayers().forEach(p -> c.accept(p));
+                    ChatChannel.getDevChannel().forEach((p) -> c.accept(p));
                     break;
                 case "server":
                     c.accept(KajetansMod.server);

+ 4 - 6
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -51,13 +51,11 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
 
 public class ScriptEvents extends ModuleListener
 {               
-    private final HashMap<UUID, UUID> questJoin;
     private final SnuviParser parser;
                  
     public ScriptEvents(Module m)
     {    
         super(m);
-        questJoin = new HashMap<>();
         parser = KajetansMod.scripts.getSnuviParser();
     }  
     
@@ -113,7 +111,7 @@ public class ScriptEvents extends ModuleListener
 
     public void onPlayerMove(EntityPlayer p)
     {      
-        handleEvent(p, "player_move", null);
+        handleEvent(p, "player_move", sc -> {});
     }
     
     public boolean onInventoryClick(Script script, SnuviInventory inv, int slot, ClickType click, EntityPlayer p)
@@ -148,13 +146,13 @@ public class ScriptEvents extends ModuleListener
     @SubscribeEvent
     public void onPlayerPostRespawn(PlayerRespawnEvent e)
     {
-        handleEvent(e.player, "player_post_respawn", null);
+        handleEvent(e.player, "player_post_respawn", sc -> {});
     }
     
     @SubscribeEvent
     public void onPlayerPreRespawn(PlayerPreRespawnEvent e)
     {
-        handleEvent(e.getEntityPlayer(), "player_pre_respawn", null);
+        handleEvent(e.getEntityPlayer(), "player_pre_respawn", sc -> {});
     }
     
     @SubscribeEvent
@@ -450,7 +448,7 @@ public class ScriptEvents extends ModuleListener
         {
             return;
         }
-        handleEvent(p, "player_logout", null);
+        handleEvent(p, "player_logout", sc -> {});
     }
     
     @SubscribeEvent

+ 7 - 3
src/main/java/me/km/snuviscript/ScriptModule.java

@@ -12,6 +12,8 @@ import java.util.List;
 import java.util.UUID;
 import me.hammerle.snuviscript.code.Script;
 import me.hammerle.snuviscript.code.SnuviParser;
+import me.km.chatchannel.ChatChannel;
+import me.km.events.CustomEventCaller;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.util.text.TextFormatting;
 
@@ -128,7 +130,7 @@ public class ScriptModule extends Module
         if(sc == null)
         {
             playerScript.remove(p.getUniqueID());
-            // TODO - print warning for devs
+            ChatChannel.getDevChannel().sendWarning("Das ungültige Script von '" + p.getName() + "' wurde entfernt. (1)");
             return null;
         }
         return sc;
@@ -152,7 +154,7 @@ public class ScriptModule extends Module
             Script sc = parser.getScript(id);
             if(sc == null)
             {
-                // TODO - print warning for devs
+                ChatChannel.getDevChannel().sendWarning("Das ungültige Script von '" + p.getName() + "' wurde entfernt. (2)");
                 return true;
             }
             parser.termSafe(sc);
@@ -186,6 +188,8 @@ public class ScriptModule extends Module
         {
             getPlayerList(sc.getId()).forEach(pl -> playerScript.remove(pl.getUniqueID()));
             registeredPlayers.remove(sc.getId());
+            
+            CustomEventCaller.removeScriptData(sc);
         }, ".txt", names);
         return true;
     }
@@ -193,6 +197,6 @@ public class ScriptModule extends Module
     public void startScript(String... names)
     {
         Arrays.setAll(names, i -> "scripts/" + names[i]);
-        parser.startScript(true, ".txt", names);
+        parser.startScript(true, sc -> {}, sc -> CustomEventCaller.removeScriptData(sc), ".txt", names);
     }
 }

+ 21 - 24
src/main/java/me/km/snuviscript/SnuviLogger.java

@@ -4,6 +4,7 @@ import me.hammerle.snuviscript.code.ISnuviLogger;
 import me.hammerle.snuviscript.code.Script;
 import me.km.KajetansMod;
 import me.km.api.Module;
+import me.km.chatchannel.ChatChannel;
 
 public class SnuviLogger implements ISnuviLogger
 {
@@ -35,30 +36,26 @@ public class SnuviLogger implements ISnuviLogger
             }
         }
         
-        // TODO - chat channels
-        KajetansMod.server.getPlayerList().getPlayers().forEach(p -> 
+        ChatChannel dev = ChatChannel.getDevChannel();
+        if(scriptname != null)
         {
-            Module m = KajetansMod.scripts;
-            if(scriptname != null)
-            {
-                m.sendWarning(p, "error in '" + scriptname + "'");
-            }
-            if(message != null)
-            {
-                m.sendHelpListElement(p, "message", message);
-            }
-            if(ex != null)
-            {
-                m.sendHelpListElement(p, "exception", ex.getClass().getSimpleName());
-            }
-            if(function != null)
-            {
-                m.sendHelpListElement(p, "function", function);
-            }
-            if(line != -1)
-            {
-                m.sendHelpListElement(p, "Zeile", String.valueOf(line));
-            }
-        });
+            dev.sendWarning("error in '" + scriptname + "'");
+        }
+        if(message != null)
+        {
+            dev.sendList("message", message);
+        }
+        if(ex != null)
+        {
+            dev.sendList("exception", ex.getClass().getSimpleName());
+        }
+        if(function != null)
+        {
+            dev.sendList("function", function);
+        }
+        if(line != -1)
+        {
+            dev.sendList("Zeile", String.valueOf(line));
+        }
     }
 }