Kajetan Johannes Hammerle 7 년 전
부모
커밋
e0d6934422

+ 0 - 1
src/main/java/me/km/ClientProxy.java

@@ -28,7 +28,6 @@ import net.minecraft.entity.Entity;
 import net.minecraft.init.Blocks;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
-import net.minecraft.server.MinecraftServer;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.ColorizerFoliage;

+ 3 - 0
src/main/java/me/km/KajetansMod.java

@@ -186,6 +186,9 @@ public class KajetansMod
         }
         
         // Datenbankverbindung
+        System.out.println(conf.exists());
+        System.out.println(conf.getString("user", "root"));
+        System.out.println(conf.getString("password", ""));
         databank = new DataBank("DataBank", "DataBank", TextFormatting.RED, conf.getString("user", "root"), conf.getString("password", ""));
         if(!databank.openDataBankConnection())
         {

+ 5 - 0
src/main/java/me/km/commands/CommandTime.java

@@ -21,6 +21,11 @@ public class CommandTime extends ModuleCommand
     @Override
     public boolean execute(ICommandSender cs, String[] arg) 
     {
+        if(!(cs instanceof EntityPlayer))
+        {
+            this.getModule().send(cs, GlobalText.onlyPlayer());
+            return true;
+        }
         if(arg.length == 0)
         {
             return false;

+ 1 - 1
src/main/java/me/km/permissions/PermissionManager.java

@@ -112,7 +112,7 @@ public class PermissionManager extends Module implements ICommandManager
     @Override
     public boolean executeCustomCommand(ICommandSender cs, String command, String[] args) 
     {
-        System.out.println(command + " " + String.join(" ", args));
+        //System.out.println(command + " " + String.join(" ", args));
         if(cs instanceof EntityPlayer && KajetansMod.scripts.isRegisteredScriptCommand(command))
         {
             KajetansMod.scripts.getEvent(ScriptEvents.class).onCustomCommand((EntityPlayer) cs, command, args);

+ 82 - 84
src/main/java/me/km/permissions/Permissions.java

@@ -26,102 +26,100 @@ public class Permissions
     public final static String HEAL = "heal"; 
     public final static String SET_BED = "setbed"; 
     public final static String TEMP_BAN = "tempban"; 
-    public final static String TELEPORT = "xxx"; 
-    public final static String SPAWNER = "xxx"; 
-    public final static String SUMMON = "xxx"; 
-    public final static String SKULL = "xxx"; 
-    public final static String SILENT = "xxx"; 
-    public final static String SIGN = "xxx"; 
-    public final static String SET_WARP = "xxx"; 
-    public final static String DEL_WARP = "xxx"; 
-    public final static String FLY = "xxx"; 
-    public final static String FLY_OTHER = "xxx"; 
-    public final static String GAMEMODE = "xxx"; 
-    public final static String GAMEMODE_OTHER = "xxx"; 
-    public final static String GOD = "xxx"; 
-    public final static String MORE = "xxx"; 
-    public final static String LASTSEEN = "xxx"; 
-    public final static String HOME = "xxx"; 
-    public final static String HOME_OTHER = "xxx"; 
-    public final static String DEL_HOME = "xxx"; 
-    public final static String KILL = "xxx"; 
-    public final static String KILL_OTHER = "xxx"; 
-    public final static String HAT = "xxx"; 
-    public final static String LIST = "xxx"; 
-    public final static String REPAIR = "xxx"; 
-    public final static String PVP = "xxx"; 
-    public final static String PVP_OTHER = "xxx"; 
-    public final static String LIGHTUPDATE = "xxx"; 
-    public final static String LAG = "xxx"; 
-    public final static String COORDS = "xxx"; 
-    public final static String INVSEE = "xxx"; 
-    public final static String SET_HOME = "xxx"; 
-    public final static String KICK = "xxx"; 
-    public final static String ADD_USER = "xxx"; 
-    public final static String ENDERCHEST = "xxx"; 
-    public final static String EXP = "xxx"; 
-    public final static String SAY = "xxx";
-    public final static String BAN = "xxx"; 
-    public final static String BACK = "xxx";
-    public final static String BED = "xxx";
-    public final static String BED_OTHER = "xxx"; 
-    public final static String POTION = "xxx"; 
-    public final static String MSG = "xxx";
-    public final static String ANSWER = "xxx";
-    public final static String ITEMINFO = "xxx"; 
-    public final static String FEED = "xxx";
-    public final static String MEMORY = "xxx";
-    public final static String POSITION = "xxx"; 
-    public final static String SEEN = "xxx"; 
-    public final static String TIME = "xxx";
-    public final static String TOP = "xxx"; 
-    public final static String TP_POS = "xxx"; 
-    public final static String USER = "xxx"; 
-    public final static String WARP = "xxx";
-    public final static String BOOK = "xxx"; 
-    public final static String GROW = "xxx";
-    public final static String ENCHANT = "xxx";
-    public final static String SPEED = "xxx";
-    public final static String TELEPORT_ACCEPT = "xxx";
-    public final static String WORLD = "xxx"; 
-    public final static String WEATHER = "xxx";
-    public final static String GAMERULE = "xxx";
+    public final static String TELEPORT = "teleport"; 
+    public final static String SPAWNER = "spawner"; 
+    public final static String SUMMON = "summon"; 
+    public final static String SKULL = "skull"; 
+    public final static String SILENT = "silent"; 
+    public final static String SIGN = "sign"; 
+    public final static String SET_WARP = "setwarp"; 
+    public final static String DEL_WARP = "delwarp"; 
+    public final static String FLY = "fly"; 
+    public final static String FLY_OTHER = "fly.other"; 
+    public final static String GAMEMODE = "gamemode"; 
+    public final static String GAMEMODE_OTHER = "gamemode.other"; 
+    public final static String GOD = "god"; 
+    public final static String MORE = "more"; 
+    public final static String LASTSEEN = "lastseen"; 
+    public final static String HOME = "home"; 
+    public final static String HOME_OTHER = "home.other"; 
+    public final static String DEL_HOME = "delhome"; 
+    public final static String KILL = "kill"; 
+    public final static String KILL_OTHER = "kill.other"; 
+    public final static String HAT = "hat"; 
+    public final static String LIST = "list"; 
+    public final static String REPAIR = "repair"; 
+    public final static String PVP = "pvp"; 
+    public final static String PVP_OTHER = "pvp.other"; 
+    public final static String LIGHTUPDATE = "lightupdate"; 
+    public final static String LAG = "lag"; 
+    public final static String COORDS = "coors"; 
+    public final static String INVSEE = "invsee"; 
+    public final static String SET_HOME = "sethome"; 
+    public final static String KICK = "kick"; 
+    public final static String ADD_USER = "adduser"; 
+    public final static String ENDERCHEST = "enderchest"; 
+    public final static String EXP = "exp"; 
+    public final static String SAY = "say";
+    public final static String BAN = "ban"; 
+    public final static String BACK = "back";
+    public final static String BED = "bed";
+    public final static String BED_OTHER = "bed.other"; 
+    public final static String POTION = "potion"; 
+    public final static String MSG = "msg";
+    public final static String ANSWER = "answer";
+    public final static String ITEMINFO = "iteminfo"; 
+    public final static String FEED = "feed";
+    public final static String MEMORY = "memory";
+    public final static String POSITION = "position"; 
+    public final static String SEEN = "seen"; 
+    public final static String TIME = "time";
+    public final static String TOP = "top"; 
+    public final static String TP_POS = "tppos"; 
+    public final static String USER = "user"; 
+    public final static String WARP = "warp";
+    public final static String BOOK = "book"; 
+    public final static String GROW = "grow";
+    public final static String ENCHANT = "enchant";
+    public final static String SPEED = "speed";
+    public final static String TELEPORT_ACCEPT = "teleportaccept";
+    public final static String WORLD = "world"; 
+    public final static String WEATHER = "weather";
+    public final static String GAMERULE = "gamerule";
 
     // Data-Tools
-    public final static String DATATOOLS = "xxx"; 
-    public final static String VILLAGER = "xxx"; 
-    public final static String HUMAN = "xxx"; 
+    public final static String DATATOOLS = "datatools"; 
+    public final static String VILLAGER = "villager"; 
+    public final static String HUMAN = "human"; 
 
     // Effects
-    public final static String WAND = "xxx"; 
+    public final static String WAND = "wand"; 
 
     // Environment
-    public final static String HEAL_STATS = "xxx"; 
-    public final static String TEMPERATURE = "xxx"; 
+    public final static String HEAL_STATS = "healstats"; 
+    public final static String TEMPERATURE = "temperature"; 
 
     // Jobs
-    public final static String JOB = "xxx"; 
-    public final static String RECIPE = "xxx";
-    public final static String ACTIVE_SKILLS = "xxx"; 
-    public final static String SKILLS = "xxx";
+    public final static String JOB = "job"; 
+    public final static String RECIPE = "recipe";
+    public final static String ACTIVE_SKILLS = "activeskills"; 
+    public final static String SKILLS = "skills";
 
     // Plots
-    public final static String PLOT = "xxx"; 
-    public final static String PLOT_CREATE = "xxx";
-    public final static String PLOT_INFO = "xxx"; 
-    public final static String PLOT_TAG = "xxx"; 
-    public final static String PLOT_SHARE = "xxx"; 
-    public final static String PLOT_SIGN = "xxx"; 
-    public final static String PLOT_BYPASS = "xxx";
-    public final static String PLOT_MARK = "xxx"; 
+    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"; 
 
     // Scrolls
-    public final static String SCROLL = "xxx"; 
+    public final static String SCROLL = "scroll"; 
 
     // Quests / Scripts
-    public final static String QUEST = "xxx"; 
-    public final static String SCRIPT = "xxx"; 
-    public final static String QUESTINFO = "xxx"; 
-    public final static String GIVEUP = "xxx"; 
-    public final static String SCRIPT_ERROR = "xxx"; 
+    public final static String SCRIPT = "script"; 
+    public final static String GIVEUP = "giveup"; 
+    public final static String SCRIPT_ERROR = "script.error";
 }

+ 11 - 2
src/main/java/me/km/snuviscript/CommandScript.java

@@ -6,6 +6,7 @@ import me.km.api.Module;
 import me.km.api.ModuleCommand;
 import java.util.Collection;
 import me.hammerle.snuviscript.code.Script;
+import me.hammerle.snuviscript.variable.Variable;
 import me.km.api.GlobalText;
 import me.km.api.Utils;
 import me.km.exception.PlayerNotFoundException;
@@ -74,7 +75,15 @@ public class CommandScript extends ModuleCommand
                             {
                                 throw new NumberFormatException();
                             }
-                            m.send(cs, arg[2] + " = " + sc.getVar(arg[2]).get(sc));
+                            Variable var = sc.getVar(arg[2]);
+                            if(var != null)
+                            {
+                                m.send(cs, arg[2] + " = " + var.get(sc));
+                            }
+                            else
+                            {
+                                m.send(cs, arg[2] + " = null");
+                            }
                         }
                         catch(NumberFormatException ex)
                         {
@@ -269,7 +278,7 @@ public class CommandScript extends ModuleCommand
         m.sendHelpListElement(cs, "start <scripts...>", "Startet ein Script");
         m.sendHelpListElement(cs, "startp <player> <scripts...>", "Startet ein Script");
         m.sendHelpListElement(cs, "variable <id> <name>", "Zeigt den Wert einer Variable");       
-        m.sendHelpListElement(cs, "printvars <id> [starts]", "Zeigt alle Variablen");
+        //m.sendHelpListElement(cs, "printvars <id> [starts]", "Zeigt alle Variablen");
         //m.sendHelpListElement(cs, "printlists <id> [starts]", "Zeigt alle Listen");
         //m.sendHelpListElement(cs, "printmaps <id> [starts]", "Zeigt alle Maps");
         m.sendHelpListElement(cs, "next <id>", "Springt in die nächste Codezeile");

+ 36 - 10
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -67,6 +67,7 @@ import me.km.effects.Effect;
 import me.km.events.CustomEventCaller;
 import me.km.events.PlayerMoveData;
 import me.km.exception.IllegalStringException;
+import me.km.exception.PlayerNotFoundException;
 import me.km.inventory.CustomContainer;
 import me.km.networking.ModPacketHandler;
 import me.km.pathfinder.PathfinderUtils;
@@ -366,7 +367,7 @@ public class MinecraftFunctions
             return Void.TYPE; 
         });
         parser.registerFunction("player.silentjoin", (sc, in) -> KajetansMod.perms.hasPermission((EntityPlayer) in[0].get(sc), Permissions.SILENT) && KajetansMod.generalCommands.getCommand(CommandSilent.class).silentjoin);
-
+        
         // ---------------------------------------------------------------------    
         // Players-Bibliothek
         // --------------------------------------------------------------------- 
@@ -1449,24 +1450,39 @@ public class MinecraftFunctions
         });
         
         // ---------------------------------------------------------------------  
-        // Quest-Bibliothek   
+        // Script-Bibliothek   
         // ---------------------------------------------------------------------    
-        parser.registerFunction("quest.playerstolist", (sc, in) -> 
+        parser.registerFunction("script.playerstolist", (sc, in) -> 
         {  
             in[0].set(sc, new ArrayList<>(KajetansMod.scripts.getPlayerList(sc.getId()))); 
             return Void.TYPE; 
         }); 
-        parser.registerFunction("quest.getplayeramount", (sc, in) -> new Fraction(KajetansMod.scripts.getPlayerList(sc.getId()).size())); 
-        parser.registerFunction("quest.start", (sc, in) -> 
+        parser.registerFunction("script.getplayeramount", (sc, in) -> new Fraction(KajetansMod.scripts.getPlayerList(sc.getId()).size())); 
+        parser.registerFunction("script.start", (sc, in) -> 
         {  
-            String[] names = new String[in.length - 1];
+            Object o = in[0].get(sc);
+            if(o instanceof EntityPlayer)
+            {
+                String[] names = new String[in.length - 1];
+                for(int i = 1; i < in.length; i++)
+                {
+                    names[i - 1] = in[i].getString(sc);
+                }
+                return KajetansMod.scripts.startPlayerScript((EntityPlayer) in[0].get(sc), names);
+            }
+            String[] names = new String[in.length];
+            names[0] = o.toString();
             for(int i = 1; i < in.length; i++)
             {
                 names[i - 1] = in[i].getString(sc);
             }
-            return KajetansMod.scripts.startPlayerScript((EntityPlayer) in[0].get(sc), names);
+            KajetansMod.scripts.startScript(names);
+            return true;
         });
-        parser.registerFunction("quest.getleader", (sc, in) -> 
+        parser.registerFunction("script.get", (sc, in) -> KajetansMod.scripts.getScript(in[0].getString(sc)));
+        parser.registerFunction("script.join", (sc, in) -> KajetansMod.scripts.registerPlayer((Script) in[0].get(sc), (EntityPlayer) in[1].get(sc)));
+        parser.registerFunction("script.kick", (sc, in) -> KajetansMod.scripts.unregisterPlayer((EntityPlayer) in[0].get(sc)));
+        parser.registerFunction("script.getleader", (sc, in) -> 
         { 
             List<EntityPlayer> players = KajetansMod.scripts.getPlayerList(sc.getId());
             if(players.isEmpty())
@@ -1610,7 +1626,17 @@ public class MinecraftFunctions
         // ---------------------------------------------------------------------  
         // Read-Bibliothek   
         // ---------------------------------------------------------------------
-        parser.registerFunction("read.player", (sc, in) -> Utils.getPlayerByName(in[0].getString(sc)));
+        parser.registerFunction("read.player", (sc, in) -> 
+        {
+            try
+            {
+                return Utils.getPlayerByName(in[0].getString(sc));
+            }
+            catch(PlayerNotFoundException ex)
+            {
+                return null;
+            }
+        });
         parser.registerFunction("read.location", (sc, in) -> new Location(in[0].getString(sc)));
         parser.registerFunction("read.item", (sc, in) -> 
         {
@@ -1766,7 +1792,7 @@ public class MinecraftFunctions
     // Gruppen-Handler
     // --------------------------------------------------------------------------------- 
 
-    private static void doForGroup(Object group, Script sc, Consumer<ICommandSender> c)
+    public static void doForGroup(Object group, Script sc, Consumer<ICommandSender> c)
     {
         if(group instanceof String)
         {

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

@@ -35,16 +35,30 @@ public class SnuviLogger implements ISnuviLogger
             }
         }
         
-        // TODO after chat channels are made
-        /*sendToDevsWithSuffix("§cError in '" + s + "'");
-        if(line != -1)
+        // TODO - chat channels
+        KajetansMod.server.getPlayerList().getPlayers().forEach(p -> 
         {
-            sendToDevsWithHelpList("§cZeile:", String.valueOf(line));
-        }
-        sendToDevsWithHelpList("§cFehler:", ex.getClass().getSimpleName() + " - " + ex.getLocalizedMessage());
-        if(function != null)
-        {
-            sendToDevsWithHelpList("§cFunktion: ", function);
-        }*/
+            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));
+            }
+        });
     }
 }