-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# NoConsoleCmds | ||
A spigot plugin that blocks console from executing specific commands | ||
A spigot plugin that blocks console from executing commands | ||
|
||
By default, the plugin blocks the command 'list' to prevent multicraft from spamming the console. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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>systems.amit.spigot.noconsolecmds</groupId> | ||
<artifactId>NoConsoleCmds</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<build.number>666</build.number> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<!--Spigot API--> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.8.8-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
<build> | ||
<finalName>NoConsoleCmds</finalName> | ||
</build> | ||
</project> |
55 changes: 55 additions & 0 deletions
55
src/main/java/systems/amit/spigot/noconsolecmds/NoConsoleCmds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package systems.amit.spigot.noconsolecmds; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.server.ServerCommandEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class NoConsoleCmds extends JavaPlugin implements Listener { | ||
|
||
private ArrayList<String> blockedCmds = new ArrayList<>(); | ||
|
||
@Override | ||
public void onEnable() { | ||
if (!loadConfig()) { | ||
getLogger().severe("Could not load config, disabling."); | ||
Bukkit.getPluginManager().disablePlugin(this); | ||
return; | ||
} | ||
|
||
getServer().getPluginManager().registerEvents(this, this); | ||
|
||
getLogger().info("The plugin has been enabled (" + blockedCmds.size() + " blocked commands)"); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
blockedCmds.clear(); | ||
getLogger().info("The plugin has been disabled"); | ||
} | ||
|
||
private boolean loadConfig() { | ||
saveDefaultConfig(); | ||
if (!getConfig().contains("commands-blocked")) { | ||
getLogger().severe("The config is missing the 'commands-blocked' section"); | ||
return false; | ||
} | ||
blockedCmds.addAll(getConfig().getStringList("commands-blocked")); | ||
if (blockedCmds.size() == 0) { | ||
getLogger().severe("No commands listed in config."); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST) | ||
public void onConsoleCommand(ServerCommandEvent e) { | ||
if (blockedCmds.contains(e.getCommand())) { | ||
e.setCancelled(true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
commands-blocked: | ||
- list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: NoConsoleCmds | ||
author: amit177 | ||
version: 1.0 | ||
description: A plugin that blocks console from executing commands | ||
main: systems.amit.spigot.noconsolecmds.NoConsoleCmds | ||
commands: |