Added files
This commit is contained in:
commit
fc6ec36267
7 changed files with 132 additions and 0 deletions
7
.classpath
Normal file
7
.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server (build)/spigot-1.9.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/bin/
|
17
.project
Normal file
17
.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OneCommandHelper</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
.settings/org.eclipse.jdt.core.prefs
Normal file
11
.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
5
plugin.yml
Normal file
5
plugin.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name: OneCommandHelper
|
||||
main: io.github.norbipeti.onecommandhelper.PluginMain
|
||||
version: 1.0
|
||||
commands:
|
||||
occ:
|
79
src/io/github/norbipeti/onecommandhelper/Commands.java
Normal file
79
src/io/github/norbipeti/onecommandhelper/Commands.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package io.github.norbipeti.onecommandhelper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Commands implements CommandExecutor
|
||||
{
|
||||
private final String[] replacecmds = { "achievement", "ban", "ban",
|
||||
"ban-ip", "banlist", "blockdata", "clear", "clone", "debug",
|
||||
"defaultgamemode", "deop", "difficulty", "effect", "enchant",
|
||||
"entitydata", "execute", "fill", "gamemode", "gamerule", "give",
|
||||
"help", "kick", "kill", "list", "me", "op", "pardon", "particle",
|
||||
"playsound", "publish", "replaceitem", "save", "save-all",
|
||||
"save-off", "save-on", "say", "scoreboard", "seed", "setblock",
|
||||
"setidletimeout", "setworldspawn", "spawnpoint", "spreadplayers",
|
||||
"stats", "stop", "stopsound", "summon", "teleport", "tell",
|
||||
"tellraw", "testfor", "testforblock", "testforblocks", "time",
|
||||
"title", "toggledownfall", "tp", "trigger", "weather", "whitelist",
|
||||
"worldborder", "xp", "commands", "banip", "broadcast", "home",
|
||||
"setspawn", "solid", "unban" };
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||
String[] args)
|
||||
{
|
||||
//System.out.println("A");
|
||||
StringBuilder acmdb = new StringBuilder("minecraft:execute @p ~ ~ ~");
|
||||
if (sender != Bukkit.getConsoleSender()
|
||||
&& !(sender instanceof BlockCommandSender))
|
||||
{
|
||||
sender.sendMessage("§cThis command can only be used from the console or a command block.");
|
||||
//return true;
|
||||
Block block = ((Player) sender).getLocation().subtract(0, 1, 0)
|
||||
.getBlock();
|
||||
if (block.getType() != Material.COMMAND)
|
||||
{
|
||||
sender.sendMessage("§cError! Block underneath must be command block! Found "
|
||||
+ block.getType());
|
||||
return true;
|
||||
}
|
||||
CommandBlock cmdblock = (CommandBlock) block.getState();
|
||||
acmdb.append(" ").append(cmdblock.getCommand());
|
||||
}
|
||||
//System.out.println("B");
|
||||
else
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /" + alias + " <onecommand>");
|
||||
return true; //yolo
|
||||
}
|
||||
//System.out.println("C");
|
||||
for (String arg : args)
|
||||
acmdb.append(" ").append(arg);
|
||||
}
|
||||
//System.out.println("D");
|
||||
String acmd = acmdb.toString();
|
||||
//System.out.println("E");
|
||||
StringBuilder replace = new StringBuilder("(" + replacecmds[0]);
|
||||
for (int i = 1; i < replacecmds.length; i++)
|
||||
replace.append("|" + replacecmds[i]);
|
||||
replace.append(")");
|
||||
//System.out.println("F");
|
||||
acmd = acmd.replaceAll("Command:\\/" + replace, "/minecraft:$1")
|
||||
.replaceAll("Command\\:" + replace, "Command:minecraft:$1")
|
||||
.replaceAll(" " + replace + " ", " minecraft:$1 ");
|
||||
//System.out.println(acmd);
|
||||
//System.out.println(replace);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd);
|
||||
return true;
|
||||
}
|
||||
}
|
12
src/io/github/norbipeti/onecommandhelper/PluginMain.java
Normal file
12
src/io/github/norbipeti/onecommandhelper/PluginMain.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package io.github.norbipeti.onecommandhelper;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PluginMain extends JavaPlugin
|
||||
{
|
||||
@Override
|
||||
public void onEnable() {
|
||||
//getServer().getPluginManager().registerEvents(new CommandListener(), this);
|
||||
getCommand("occ").setExecutor(new Commands());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue