diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..d1dce1e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +CHProtocolSupport \ No newline at end of file diff --git a/.idea/artifacts/CHProtocolSupport.xml b/.idea/artifacts/CHProtocolSupport.xml new file mode 100644 index 0000000..023a42e --- /dev/null +++ b/.idea/artifacts/CHProtocolSupport.xml @@ -0,0 +1,8 @@ + + + D:/Server/CH/1.9/plugins/CommandHelper/extensions + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7e725c2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..be3f4e4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CHProtocolSupport.iml b/CHProtocolSupport.iml new file mode 100644 index 0000000..84472f6 --- /dev/null +++ b/CHProtocolSupport.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/ProtocolSupport.jar b/libs/ProtocolSupport.jar new file mode 100644 index 0000000..5147b03 Binary files /dev/null and b/libs/ProtocolSupport.jar differ diff --git a/libs/commandhelper-3.3.2-SNAPSHOT.jar b/libs/commandhelper-3.3.2-SNAPSHOT.jar new file mode 100644 index 0000000..fd408f3 Binary files /dev/null and b/libs/commandhelper-3.3.2-SNAPSHOT.jar differ diff --git a/libs/spigot.jar b/libs/spigot.jar new file mode 100644 index 0000000..c7716ac Binary files /dev/null and b/libs/spigot.jar differ diff --git a/src/tk/itstake/chprotocolsupport/Functions.java b/src/tk/itstake/chprotocolsupport/Functions.java new file mode 100644 index 0000000..d1271e6 --- /dev/null +++ b/src/tk/itstake/chprotocolsupport/Functions.java @@ -0,0 +1,102 @@ +package tk.itstake.chprotocolsupport; + +import com.laytonsmith.PureUtilities.SimpleVersion; +import com.laytonsmith.PureUtilities.Version; +import com.laytonsmith.abstraction.MCCommandSender; +import com.laytonsmith.abstraction.bukkit.entities.BukkitMCPlayer; +import com.laytonsmith.annotations.api; +import com.laytonsmith.core.ObjectGenerator; +import com.laytonsmith.core.Static; +import com.laytonsmith.core.constructs.CString; +import com.laytonsmith.core.constructs.Construct; +import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.CommandHelperEnvironment; +import com.laytonsmith.core.environments.Environment; +import com.laytonsmith.core.exceptions.CRE.CREInvalidPluginException; +import com.laytonsmith.core.exceptions.CRE.CRENotFoundException; +import com.laytonsmith.core.exceptions.CRE.CREPlayerOfflineException; +import com.laytonsmith.core.exceptions.CRE.CREThrowable; +import com.laytonsmith.core.exceptions.ConfigRuntimeException; +import com.laytonsmith.core.functions.AbstractFunction; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import protocolsupport.api.ProtocolSupportAPI; +import sun.security.ssl.ProtocolVersion; + +import java.net.SocketAddress; + +/** + * Created by bexco on 2016-03-12. + */ +public class Functions { + + public String docs() { + return "Functions about ProtocolSupport API"; + } + + private static void checkPlugin(Target t) { + if(!Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport")) { + throw new CREInvalidPluginException("Can't find ProtocolSupport", t); + } + } + + @api + public static class get_protocol_version extends AbstractFunction { + + @Override + public Class[] thrown() { + return new Class[]{ + CREInvalidPluginException.class, + CREPlayerOfflineException.class, + CRENotFoundException.class + }; + } + + @Override + public boolean isRestricted() { + return false; + } + + @Override + public Boolean runAsync() { + return false; + } + + @Override + public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException { + checkPlugin(t); + Player p = null; + if(args.length == 0) { + MCCommandSender m = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); + if (m instanceof BukkitMCPlayer) { + p = ((BukkitMCPlayer) m)._Player(); + } else { + throw new CREPlayerOfflineException("Player is Offline or Not exist", t); + } + } else if(args.length == 1) { + p = ((BukkitMCPlayer) Static.GetPlayer(args[0], t))._Player(); + } + return new CString(ProtocolSupportAPI.getProtocolVersion(p).getName(), t); + } + + @Override + public String getName() { + return "get_protocol_version"; + } + + @Override + public Integer[] numArgs() { + return new Integer[]{0, 1}; + } + + @Override + public String docs() { + return "{[player]} version Returns a Protocol Version."; + } + + @Override + public Version since() { + return new SimpleVersion(1, 0, 0); + } + } +} diff --git a/src/tk/itstake/chprotocolsupport/LifeCylcles.java b/src/tk/itstake/chprotocolsupport/LifeCylcles.java new file mode 100644 index 0000000..c4f6f72 --- /dev/null +++ b/src/tk/itstake/chprotocolsupport/LifeCylcles.java @@ -0,0 +1,29 @@ +package tk.itstake.chprotocolsupport; + +import com.laytonsmith.PureUtilities.SimpleVersion; +import com.laytonsmith.PureUtilities.Version; +import com.laytonsmith.core.extensions.AbstractExtension; +import com.laytonsmith.core.extensions.MSExtension; +import org.bukkit.Bukkit; + +/** + * Created by bexco on 2016-03-12. + */ +@MSExtension("CHProtocolSupport") +public class LifeCylcles extends AbstractExtension { + + @Override + public Version getVersion() { + return new SimpleVersion(1, 0, 0); + } + + @Override + public void onStartup() { + Bukkit.getConsoleSender().sendMessage("[CommandHelper] CHProtocolSupport v" + getVersion().toString() + " Enabled."); + } + + @Override + public void onShutdown() { + Bukkit.getConsoleSender().sendMessage("[CommandHelper] CHProtocolSupport v" + getVersion().toString() + " Disabled."); + } +}