Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EATSTEAK committed Mar 16, 2016
0 parents commit 7d84651
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/CHProtocolSupport.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions CHProtocolSupport.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/libs" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/libs" />
</SOURCES>
<jarDirectory url="file://$MODULE_DIR$/libs" recursive="false" />
<jarDirectory url="file://$MODULE_DIR$/libs" recursive="false" type="SOURCES" />
</library>
</orderEntry>
</component>
</module>
Binary file added libs/ProtocolSupport.jar
Binary file not shown.
Binary file added libs/commandhelper-3.3.2-SNAPSHOT.jar
Binary file not shown.
Binary file added libs/spigot.jar
Binary file not shown.
102 changes: 102 additions & 0 deletions src/tk/itstake/chprotocolsupport/Functions.java
Original file line number Diff line number Diff line change
@@ -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<? extends CREThrowable>[] 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);
}
}
}
29 changes: 29 additions & 0 deletions src/tk/itstake/chprotocolsupport/LifeCylcles.java
Original file line number Diff line number Diff line change
@@ -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.");
}
}

0 comments on commit 7d84651

Please sign in to comment.