mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
A simple fire antigrief plugin
This commit is contained in:
parent
3793b72fae
commit
4e004558e5
1
TODO
1
TODO
@ -7,3 +7,4 @@ Bukkit TODO
|
||||
-vGroups for the groups system (Cere)
|
||||
-Finish up the hMod planned features
|
||||
-Include updatr support with the new plugins
|
||||
-Port as many of vMinecrafts features as possible
|
30
vStopFire/com/bukkit/nossr50/vStopFire/vBlockListener.java
Normal file
30
vStopFire/com/bukkit/nossr50/vStopFire/vBlockListener.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.bukkit.nossr50.vStopFire;
|
||||
|
||||
import org.bukkit.Block;
|
||||
import org.bukkit.BlockFace;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
/**
|
||||
* vPlayerSpawn block listener
|
||||
* @author nossr50
|
||||
*/
|
||||
public class vBlockListener extends BlockListener {
|
||||
private final vStopFire plugin;
|
||||
|
||||
public vBlockListener(final vStopFire plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
//This should stop fire from spreading but still allow players to light stuff up with flint and steel
|
||||
public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
String cause = event.getCause().toString();
|
||||
if(cause.equals("SPREAD"))
|
||||
event.setCancelled(true);
|
||||
if(!cause.equals("FLINT_AND_STEEL"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
//put all Block related code here
|
||||
}
|
24
vStopFire/com/bukkit/nossr50/vStopFire/vPlayerListener.java
Normal file
24
vStopFire/com/bukkit/nossr50/vStopFire/vPlayerListener.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.bukkit.nossr50.vStopFire;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
* Handle events for all Player related events
|
||||
* @author nossr50
|
||||
*/
|
||||
public class vPlayerListener extends PlayerListener {
|
||||
private final vStopFire plugin;
|
||||
|
||||
public vPlayerListener(vStopFire instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
|
||||
//Insert Player related code here
|
||||
}
|
||||
|
58
vStopFire/com/bukkit/nossr50/vStopFire/vStopFire.java
Normal file
58
vStopFire/com/bukkit/nossr50/vStopFire/vStopFire.java
Normal file
@ -0,0 +1,58 @@
|
||||
package com.bukkit.nossr50.vStopFire;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Player;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
/**
|
||||
* vStopFire for Bukkit
|
||||
*
|
||||
* @author nossr50
|
||||
*/
|
||||
public class vStopFire extends JavaPlugin {
|
||||
private final vPlayerListener playerListener = new vPlayerListener(this);
|
||||
private final vBlockListener blockListener = new vBlockListener(this);
|
||||
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
|
||||
private final String name = "vStopFire";
|
||||
|
||||
public vStopFire(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
|
||||
super(pluginLoader, instance, desc, folder, plugin, cLoader);
|
||||
|
||||
|
||||
// NOTE: Event registration should be done in onEnable not here as all events are unregistered when a plugin is disabled
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.Normal, this);
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
}
|
||||
public void onDisable() {
|
||||
// TODO: Place any custom disable code here
|
||||
|
||||
// NOTE: All registered events are automatically unregistered when a plugin is disabled
|
||||
|
||||
// EXAMPLE: Custom code, here we just output some info so we can check all is well
|
||||
System.out.println("Goodbye world!");
|
||||
}
|
||||
public boolean isDebugging(final Player player) {
|
||||
if (debugees.containsKey(player)) {
|
||||
return debugees.get(player);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDebugging(final Player player, final boolean value) {
|
||||
debugees.put(player, value);
|
||||
}
|
||||
}
|
3
vStopFire/plugin.yml
Normal file
3
vStopFire/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
||||
name: vStopFire
|
||||
main: com.bukkit.nossr50.vStopFire.vStopFire
|
||||
version: 1.0
|
Loading…
Reference in New Issue
Block a user