Using maven and fixed encoding
Also using IDEA. Also fixes based on code analysis.
This commit is contained in:
parent
6127ef829a
commit
448d8a8ce0
5 changed files with 117 additions and 86 deletions
|
@ -1,7 +0,0 @@
|
|||
<?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>
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
/bin/
|
||||
/.idea/
|
||||
*.iml
|
||||
|
|
37
pom.xml
Normal file
37
pom.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.github.NorbiPeti</groupId>
|
||||
<artifactId>OneCommandHelper</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,67 +1,67 @@
|
|||
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-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", "unban" };
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||
String[] args)
|
||||
{
|
||||
StringBuilder acmdb = new StringBuilder("minecraft:execute "
|
||||
+ sender.getName() + " ~ ~ ~ ");
|
||||
if (sender != Bukkit.getConsoleSender()
|
||||
&& !(sender instanceof BlockCommandSender))
|
||||
{
|
||||
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(cmdblock.getCommand());
|
||||
} else
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /" + alias + " <onecommand>");
|
||||
return true; //Why use the builtin usage shoing thing
|
||||
}
|
||||
}
|
||||
String acmd = acmdb.toString();
|
||||
StringBuilder replace = new StringBuilder("(" + replacecmds[0]);
|
||||
for (int i = 1; i < replacecmds.length; i++)
|
||||
replace.append("|" + replacecmds[i]);
|
||||
replace.append(")");
|
||||
acmd = acmd.replaceAll("([^t]|^)( |:| \\/|:\\/)" + replace + " ",
|
||||
"$1$2minecraft:$3 ").replaceAll("\" (\\/*)minecraft:",
|
||||
"\"$1minecraft:"); //Tellraw
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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-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", "unban" };
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||
String[] args)
|
||||
{
|
||||
StringBuilder acmdb = new StringBuilder("minecraft:execute "
|
||||
+ sender.getName() + " ~ ~ ~ ");
|
||||
if (sender != Bukkit.getConsoleSender()
|
||||
&& !(sender instanceof BlockCommandSender))
|
||||
{
|
||||
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(cmdblock.getCommand());
|
||||
} else
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /" + alias + " <onecommand>");
|
||||
return true; //Why use the builtin usage shoing thing
|
||||
}
|
||||
}
|
||||
String acmd = acmdb.toString();
|
||||
StringBuilder replace = new StringBuilder("(" + replacecmds[0]);
|
||||
for (int i = 1; i < replacecmds.length; i++)
|
||||
replace.append("|").append(replacecmds[i]);
|
||||
replace.append(")");
|
||||
acmd = acmd.replaceAll("([^t]|^)( |:| /|:/)" + replace + " ",
|
||||
"$1$2minecraft:$3 ").replaceAll("\" (/*)minecraft:",
|
||||
"\"$1minecraft:"); //Tellraw
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
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());
|
||||
}
|
||||
}
|
||||
package io.github.norbipeti.onecommandhelper;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PluginMain extends JavaPlugin
|
||||
{
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getCommand("occ").setExecutor(new Commands());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue