Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false

language: java
jdk: oraclejdk7
jdk: openjdk7

cache:
directories:
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,3 @@ SnowFall: #this is only in biomes where snow falls naturally
* Make deeper snow slow down players and/or mobs.
* Create custom snow related recipes (ideas welcome)
* Enable for snow on mountains not in a snowy biome

##
*This plugin utilizes Hidendra's plugin metrics system, which means some anonymous information will be collected and sent to mcstats.org.
This allows me to track how many servers are actually running the plugin, and the larger user base I have the more likely I am to add features.
If you wish to opt out of this service, it can be done by editing plugins/Plugin Metrics/config.yml*

<img src="http://i.mcstats.org/SnowControl/Global+Statistics.borderless.png">
##
77 changes: 22 additions & 55 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.zmanww</groupId>
<artifactId>SnowControl</artifactId>
<version>1.1.1</version>
<version>1.1.3</version>
<packaging>jar</packaging>
<name>SnowControl</name>
<inceptionYear>2013</inceptionYear>
<url>https://github.com/zwollner/SnowControl</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>SnowControl</finalName>
<defaultGoal>clean install</defaultGoal>
Expand All @@ -27,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
Expand Down Expand Up @@ -67,7 +87,6 @@
<artifactSet>
<includes>
<include>com.zmanww.*</include>
<include>org.mcstats.*:*</include>
</includes>
</artifactSet>
</configuration>
Expand All @@ -82,56 +101,4 @@
</plugin>
</plugins>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/public</url>
</repository>
<repository>
<id>Spigot Public</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public</url>
</repository>
</repositories>


<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
14 changes: 6 additions & 8 deletions src/main/java/com/zmanww/bukkit/SnowControl/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public static Config getInstance() {
public void reload() {
plugin.reloadConfig(); // Force reload
instance = null;// Force all objects to reload.

// restart the Monitor
plugin.startScheduler();
plugin.load();
plugin.startScheduler(); // restart the Monitor
}

private void loadKeys() {
Expand Down Expand Up @@ -152,11 +151,6 @@ public boolean debugEnabled() {
return plugin.getConfig().getBoolean("debug", false);
}

public boolean isMetricsEnabled()
{
return plugin.getConfig().getBoolean("Metrics", true);
}

public boolean isAccumulationEnabled() {
return plugin.getConfig().getBoolean("SnowFall.AccumulationEnabled", true);
}
Expand Down Expand Up @@ -201,4 +195,8 @@ public int getMinLightLevel() {
return plugin.getConfig().getInt("SnowFall.MinLightLevelToMelt", 12);
}

public int getMaxChunksPerCheck()
{
return Math.min(plugin.getConfig().getInt("SnowFall.MaxChunksPerWorldAndCheck", 441), 1);
}
}
15 changes: 6 additions & 9 deletions src/main/java/com/zmanww/bukkit/SnowControl/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
Expand All @@ -43,7 +44,7 @@ public PlayerListener(SnowControl instance) {
plugin = instance;
}

@EventHandler()
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void blockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.ICE) {
Expand Down Expand Up @@ -130,8 +131,7 @@ public void onBlockDamage(BlockDamageEvent event) {
event.getPlayer().sendMessage("MinSurrounding=" + SnowManager.getMinSurrounding(block, (byte) -1));
event.getPlayer().sendMessage("MaxSurrounding=" + SnowManager.getMaxSurrounding(block, (byte) -1));
event.getPlayer().sendMessage("canSnowBeAdded=" + SnowManager.canSnowBeAdded(block));
event.getPlayer().sendMessage(
"canSnowBeAddedAbove=" + SnowManager.canSnowBeAdded(block.getRelative(BlockFace.UP)));
event.getPlayer().sendMessage("canSnowBeAddedAbove=" + SnowManager.canSnowBeAdded(block.getRelative(BlockFace.UP)));

List<Block> snowBlocks = SnowManager.getBlocksToIncreaseUnder(event.getBlock());
for (Block blk : snowBlocks) {
Expand All @@ -142,10 +142,8 @@ public void onBlockDamage(BlockDamageEvent event) {
} else if (event.getItemInHand().getType() == Material.SNOW_BLOCK) {
event.getPlayer().sendMessage("Increasing Snow Level");

boolean canIncrease = false;
if (SnowManager.canSnowBeAdded(block)) {
canIncrease = true;
} else if (SnowManager.canSnowBeAdded(block.getRelative(BlockFace.UP))) {
boolean canIncrease = SnowManager.canSnowBeAdded(block);
if (!canIncrease && SnowManager.canSnowBeAdded(block.getRelative(BlockFace.UP))) {
block = block.getRelative(BlockFace.UP);
canIncrease = true;
}
Expand All @@ -172,8 +170,7 @@ public void onBlockDamage(BlockDamageEvent event) {
}
if (blk.getLightFromSky() >= 12) {
// Melt it down
SnowManager.decreaseSnowLevel(new Location(event.getBlock().getWorld(), blk.getX(), blk.getY(),
blk.getZ()));
SnowManager.decreaseSnowLevel(blk);
}
}
event.getPlayer().sendMessage("**");
Expand Down
40 changes: 18 additions & 22 deletions src/main/java/com/zmanww/bukkit/SnowControl/SnowControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
*/
package com.zmanww.bukkit.SnowControl;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.mcstats.Metrics;

public class SnowControl extends JavaPlugin implements Listener {
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

public class SnowControl extends JavaPlugin implements Listener
{
public static SnowControl plugin;

private final PlayerListener playerListener = new PlayerListener(this);
Expand All @@ -41,26 +40,22 @@ public class SnowControl extends JavaPlugin implements Listener {

public static Map<Player, String> pendingCommand = new HashMap<>();

private boolean debug = false;

private SnowMonitor snowMonitor;

public void onEnable() {
plugin = this;
load();
getServer().getPluginManager().registerEvents(playerListener, this);
getServer().getPluginManager().registerEvents(worldListener, this);
getCommand("snowcontrol").setExecutor(new CommandManager());
startScheduler();
if(Config.getInstance().isMeltingEnabled())
{
try
{
Metrics metrics = new Metrics(this);
metrics.start();
}
catch(IOException e)
{
// Failed to submit the stats :-(
}
}
}

public void load()
{
debug = Config.getInstance().debugEnabled();
}

public void startScheduler()
Expand All @@ -82,10 +77,11 @@ public void onDisable() {
this.saveConfig();
}

public void debugLog(String string) {
if (Config.getInstance().debugEnabled()) {
public void debugLog(String string)
{
if (debug)
{
this.getLogger().log(Level.INFO, "<DEBUG> " + string);
}

}
}
24 changes: 4 additions & 20 deletions src/main/java/com/zmanww/bukkit/SnowControl/SnowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Random;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
Expand Down Expand Up @@ -85,20 +84,10 @@ public static int getSnowDepth(Block block) {
}

public static boolean canSnowInBiome(Biome biome) {
if (biome.name().toUpperCase().contains("ICE_")) {
return true;
}
if (biome.name().toUpperCase().contains("COLD_")) {
return true;
}
if (biome.name().toUpperCase().contains("FROZEN_")) {
return true;
}
return false;
return biome.name().contains("ICE_") || biome.name().contains("COLD_") || biome.name().contains("_COLD") || biome.name().contains("FROZEN_");
}

public static void decreaseSnowLevel(Location loc) {
Block block = loc.getBlock();
public static void decreaseSnowLevel(Block block) {
if (block.getType() == Material.SNOW || block.getType() == Material.SNOW_BLOCK) {
byte blkData = getSnowValue(block);
if (blkData >= getMinSurrounding(block, (byte) 0) && blkData > getMaxSurrounding(block, (byte) 0, true) - 2) {
Expand Down Expand Up @@ -252,20 +241,15 @@ public static boolean canAccumulateOn(final Block block) {
// This is essentially a full block
return true;
}
if (Config.getInstance().canAccumulateOn.contains(block.getType())) {
return true;
}
return false;
return Config.getInstance().canAccumulateOn.contains(block.getType());
}

public static boolean canSnowBeAdded(Block block) {
if (block.getType() == Material.SNOW && block.getData() < 7) {
return true;
}
if (canAccumulateOn(block.getRelative(BlockFace.DOWN))) {
if (Config.getInstance().canReplace.contains(block.getType())) {
return true;
}
return Config.getInstance().canReplace.contains(block.getType());
}
return false;
}
Expand Down
Loading