Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F225285
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Subscribers
None
View Options
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..ebb3f86
--- /dev/null
+++ b/.classpath
@@ -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="var" path="SRCSVR/spigot-1.8.8.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6dd29b7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+bin/
\ No newline at end of file
diff --git a/.project b/.project
new file mode 100644
index 0000000..0a89773
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Togglable Spawners</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>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3a21537
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -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
diff --git a/config.yml b/config.yml
new file mode 100644
index 0000000..bee5373
--- /dev/null
+++ b/config.yml
@@ -0,0 +1,18 @@
+# ----------------------------------------
+# Togglable Spawners v1.0.1 config file
+# Created by despawningbone
+# ----------------------------------------
+
+#Choose which worlds where redstone will not be able to be used
+#for toggling the spawners.
+Disabled-in-worlds:
+ #- Disabled_World
+ -
+
+#Allow spawners to be indirectly powered?
+Allow-indirect-power: true
+
+#Enable debug logs?
+#This will output the spawner's location to the console
+#when the spawn event is fired and is cancelled by the plugin.
+debug: false
diff --git a/plugin.yml b/plugin.yml
new file mode 100644
index 0000000..ac17930
--- /dev/null
+++ b/plugin.yml
@@ -0,0 +1,12 @@
+name: TogglableSpawners
+description: A plugin that allows redstone to be used on spawners directly.
+version: 1.0.1
+author: despawningbone
+
+main: me.despawningbone.togglespawner.TSMain
+
+commands:
+ togglablespawner:
+ description: A command mainly for reloading.
+ usage: /<command> [reload]
+ aliases: [ts, togglespawner, tspawner]
\ No newline at end of file
diff --git a/src/me/despawningbone/togglespawner/ConfigHandler.java b/src/me/despawningbone/togglespawner/ConfigHandler.java
new file mode 100644
index 0000000..ce858dd
--- /dev/null
+++ b/src/me/despawningbone/togglespawner/ConfigHandler.java
@@ -0,0 +1,47 @@
+package me.despawningbone.togglespawner;
+
+import java.io.File;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class ConfigHandler {
+
+ private TSMain plugin;
+ private FileConfiguration config;
+
+ public static boolean debug = false, indirectPower = true;
+ public static List<String> disabledWorlds = new ArrayList<String>();
+
+ public ConfigHandler(TSMain instance) {
+ plugin = instance;
+ createFiles();
+ }
+
+ public void createFiles() {
+ File configFile = new File(plugin.getDataFolder() + File.separator
+ + "config.yml");
+ if (!configFile.exists()) {
+ plugin.log.info("Cannot find config.yml, Generating now....");
+ plugin.saveDefaultConfig();
+ plugin.log.info("Config generated!");
+ }
+ }
+
+ public void getConfigValues() {
+ plugin.reloadConfig();
+ config = plugin.getConfig();
+ YamlConfiguration defcfg = YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getResource("config.yml")));
+ if(!defcfg.getKeys(true).equals(config.getKeys(true))) {
+ plugin.log.warning("Config File's keys are not the same.");
+ plugin.log.warning("This can mean that your configuration file is corrupted or was tempered with wrongly.");
+ plugin.log.warning("Please reset or remove the config file in order for it to work properly.");
+ }
+ disabledWorlds = config.getStringList("Disabled-in-worlds");
+ indirectPower = config.getBoolean("Allow-indirect-power");
+ debug = config.getBoolean("debug");
+ }
+}
diff --git a/src/me/despawningbone/togglespawner/TSCommand.java b/src/me/despawningbone/togglespawner/TSCommand.java
new file mode 100644
index 0000000..dd2355e
--- /dev/null
+++ b/src/me/despawningbone/togglespawner/TSCommand.java
@@ -0,0 +1,32 @@
+package me.despawningbone.togglespawner;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+public class TSCommand implements CommandExecutor {
+
+ private TSMain plugin;
+
+ public TSCommand(TSMain instance) {
+ plugin = instance;
+
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
+ if(args.length > 0 && args[0].equalsIgnoreCase("reload")) {
+ if(sender.hasPermission("togglespawner.reload") || sender.isOp()) {
+ ConfigHandler configHandler = new ConfigHandler(plugin);
+ configHandler.getConfigValues();
+ sender.sendMessage(ChatColor.BLUE + "Togglable Spawners has been reloaded.");
+ } else {
+ sender.sendMessage(ChatColor.RED + "You do not have permission.");
+ }
+ } else {
+ sender.sendMessage("Unknown arguments.");
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/me/despawningbone/togglespawner/TSListener.java b/src/me/despawningbone/togglespawner/TSListener.java
new file mode 100644
index 0000000..03fa244
--- /dev/null
+++ b/src/me/despawningbone/togglespawner/TSListener.java
@@ -0,0 +1,32 @@
+package me.despawningbone.togglespawner;
+
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.SpawnerSpawnEvent;
+
+public class TSListener implements Listener {
+
+ private TSMain plugin;
+
+ public TSListener(TSMain instance) {
+ plugin = instance;
+ }
+
+ @EventHandler
+ public void onSpawnerSpawn(SpawnerSpawnEvent event) {
+ if(ConfigHandler.disabledWorlds.isEmpty() || !ConfigHandler.disabledWorlds.contains(event.getLocation().getWorld().getName())) {
+ Block block = event.getSpawner().getBlock();
+ if(block.getBlockPower() != 0 && (ConfigHandler.indirectPower || block.isBlockPowered())) {
+ event.setCancelled(true);
+ String mobname = event.getSpawner().getCreatureTypeName().toLowerCase();
+ if(ConfigHandler.debug) {
+ Location loc = event.getSpawner().getLocation();
+ plugin.log.info((Character.toUpperCase(mobname.charAt(0)) + mobname.substring(1)) + " spawner at world " + loc.getWorld().getName() + ":" + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + " is powered! Cancelling spawn event...");
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/me/despawningbone/togglespawner/TSMain.java b/src/me/despawningbone/togglespawner/TSMain.java
new file mode 100644
index 0000000..93d3bd1
--- /dev/null
+++ b/src/me/despawningbone/togglespawner/TSMain.java
@@ -0,0 +1,31 @@
+package me.despawningbone.togglespawner;
+
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class TSMain extends JavaPlugin {
+
+ public Logger log;
+ private TSListener listener = new TSListener(this);
+ private ConfigHandler configHandler;
+
+ String[] cmdAliases = {"ts", "togglespawner", "tspawner"};
+
+ @Override
+ public void onEnable() {
+ log = getLogger();
+ configHandler = new ConfigHandler(this);
+ configHandler.getConfigValues();
+ getServer().getPluginManager().registerEvents(listener, this);
+ getCommand("togglablespawner").setExecutor(new TSCommand(this));
+ getCommand("togglablespawner").setAliases(Arrays.asList(cmdAliases));
+ log.info("Togglable spawners v" + getDescription().getVersion() + " by despawningbone has been enabled!");
+ }
+
+ @Override
+ public void onDisable() {
+ log.info("Disabled Togglable spawners v" + getDescription().getVersion() + ".");
+ }
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Mar 15, 1:23 PM (21 h, 38 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
45/b3/e73814436d48127b6b9248e6bef0
Attached To
rTSP Togglable Spawners
Event Timeline
Log In to Comment