Skip to content

Commit 7702735

Browse files
committed
Initial commit
0 parents  commit 7702735

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
*.iml

pom.xml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.trophonix</groupId>
8+
<artifactId>redstone-spawners</artifactId>
9+
<version>1.0</version>
10+
11+
<repositories>
12+
<repository>
13+
<id>spigot-repo</id>
14+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
15+
</repository>
16+
</repositories>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.spigotmc</groupId>
21+
<artifactId>spigot-api</artifactId>
22+
<version>1.12.2-R0.1-SNAPSHOT</version>
23+
<scope>provided</scope>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<sourceDirectory>${basedir}/src/main/java/</sourceDirectory>
29+
<finalName>${project.artifactId}-${project.version}</finalName>
30+
<resources>
31+
<resource>
32+
<targetPath>.</targetPath>
33+
<filtering>true</filtering>
34+
<directory>${basedir}/src/main/resources/</directory>
35+
</resource>
36+
</resources>
37+
38+
<plugins>
39+
<plugin>
40+
<groupId>org.apache.maven.plugins</groupId>
41+
<artifactId>maven-compiler-plugin</artifactId>
42+
<version>3.1</version>
43+
<configuration>
44+
<source>1.8</source>
45+
<target>1.8</target>
46+
</configuration>
47+
</plugin>
48+
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-shade-plugin</artifactId>
52+
<version>2.1</version>
53+
<executions>
54+
<execution>
55+
<phase>package</phase>
56+
<goals>
57+
<goal>shade</goal>
58+
</goals>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
65+
</project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.trophonix.redstonespawners;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.ChatColor;
5+
import org.bukkit.block.Block;
6+
import org.bukkit.command.Command;
7+
import org.bukkit.command.CommandSender;
8+
import org.bukkit.configuration.file.YamlConfiguration;
9+
import org.bukkit.event.EventHandler;
10+
import org.bukkit.event.Listener;
11+
import org.bukkit.event.entity.SpawnerSpawnEvent;
12+
import org.bukkit.plugin.java.JavaPlugin;
13+
14+
import java.io.InputStreamReader;
15+
16+
public class RedstoneSpawners extends JavaPlugin implements Listener {
17+
18+
@Override
19+
public void onEnable() {
20+
getConfig().setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getResource("config.yml"))));
21+
getConfig().options().copyDefaults(true).copyHeader(true);
22+
saveConfig();
23+
getServer().getPluginManager().registerEvents(this, this);
24+
}
25+
26+
@Override
27+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
28+
if (args.length > 0) {
29+
switch (args[0].toLowerCase()) {
30+
case "reload":
31+
case "rl":
32+
reloadConfig();
33+
sender.sendMessage(ChatColor.RED + "[RedstoneSpawners] " + ChatColor.WHITE + "Config reloaded!");
34+
return true;
35+
}
36+
}
37+
sender.sendMessage(new String[]{
38+
" ",
39+
ChatColor.RED + "[RedstoneSpawners by Trophonix]",
40+
ChatColor.GRAY + "/rss reload " + ChatColor.WHITE + "Reload config file.",
41+
" "
42+
});
43+
return true;
44+
}
45+
46+
@EventHandler
47+
public void onSpawnerActivate(SpawnerSpawnEvent event) {
48+
Block spawner = event.getSpawner().getBlock();
49+
boolean cancel = (spawner.isBlockPowered() != getConfig().getBoolean("power-enables", true));
50+
if (cancel) event.setCancelled(true);
51+
if (getConfig().getBoolean("debug", false)) {
52+
String loc = "["
53+
+ spawner.getX() + ", " + spawner.getY() + ", " + spawner.getZ()
54+
+ "]";
55+
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[RedstoneSpawners] "
56+
+ ChatColor.WHITE + (cancel ? "Cancelled" : "Allowed") + " spawner " + loc);
57+
}
58+
}
59+
60+
}

src/main/resources/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# If true, mob spawners will only activate when powered.
2+
# If false, mob spawners will only activate when NOT powered.
3+
power-enables: true
4+
debug: false

src/main/resources/plugin.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "RedstoneSpawners"
2+
version: "${project.version}"
3+
author: "Trophonix"
4+
main: "com.trophonix.redstonespawners.RedstoneSpawners"
5+
commands:
6+
redstonespawners:
7+
description: "RedstoneSpawners admin command"
8+
aliases: [rss]
9+
permission: "redstonespawners.admin"
10+
permissions:
11+
redstonespawners.admin:
12+
default: "op"

0 commit comments

Comments
 (0)