-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> |
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); | ||
} | ||
} | ||
} |
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."); | ||
} | ||
} |