Cleaned up Creative Boundaries for public use
This commit is contained in:
parent
6b4a21d2ca
commit
c8cda48209
3 changed files with 28 additions and 29 deletions
|
@ -18,7 +18,7 @@ public class CreativeBoundariesModule extends Module{
|
|||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
registerCommand(plugin, new Cbgm1(this));
|
||||
registerCommand(plugin, new Cbgm0());
|
||||
registerCommand(plugin, new Cbgm0(this));
|
||||
registerCommand(plugin, new SetDickmode(this));
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package alisolarflare.creativeboundaries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -16,61 +13,55 @@ import com.palmergames.bukkit.towny.object.TownBlock;
|
|||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
|
||||
public class PlotChangeListener implements Listener{
|
||||
private List<Player> cbCreatives = new ArrayList<Player>();
|
||||
public CreativeBoundariesModule plugin;
|
||||
public PlotChangeListener(CreativeBoundariesModule plugin){
|
||||
this.plugin = plugin;
|
||||
this.cbCreatives = plugin.cbCreatives;
|
||||
public CreativeBoundariesModule module;
|
||||
public PlotChangeListener(CreativeBoundariesModule module){
|
||||
this.module = module;
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerPlotChange(PlayerChangePlotEvent plotEvent){
|
||||
Player player = plotEvent.getPlayer();
|
||||
player.sendMessage("PING");
|
||||
if (plugin.dickmode == false){
|
||||
debug(player, "dickies");
|
||||
if (module.dickmode == false){
|
||||
return;
|
||||
}
|
||||
if (plotEvent.getPlayer().getGameMode() != GameMode.CREATIVE){
|
||||
debug(player, "cray cray");
|
||||
return;
|
||||
}
|
||||
if (!(cbCreatives.contains(plotEvent.getPlayer()))){
|
||||
debug(player, "racism");
|
||||
if (!(module.cbCreatives.contains(plotEvent.getPlayer()))){
|
||||
return;
|
||||
}
|
||||
player.sendMessage("PONG");
|
||||
TownBlock tb = TownyUniverse.getTownBlock(player.getLocation());
|
||||
if (tb == null) {
|
||||
player.sendMessage("You aren't standing in a town or some other error occured.");
|
||||
player.sendMessage("TownBlock is null.");
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.sendMessage("You have left your town boundaries!");
|
||||
module.cbCreatives.remove(player);
|
||||
return;
|
||||
}
|
||||
Town town;
|
||||
try {
|
||||
town = tb.getTown();
|
||||
} catch (NotRegisteredException e) {
|
||||
player.sendMessage("You aren't standing in a town or some other error occured.");
|
||||
player.sendMessage("TownBlock's town is not registered.");
|
||||
return;
|
||||
}
|
||||
if (town == null) {
|
||||
player.sendMessage("ERROR: The town you're standing in is Null.");
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.sendMessage("You have left your town boundaries!!");
|
||||
module.cbCreatives.remove(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (town == null) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.sendMessage("You have left your town boundaries!!!");
|
||||
module.cbCreatives.remove(player);
|
||||
return;
|
||||
}
|
||||
boolean townHasRes = false;
|
||||
for(Resident res : town.getResidents()){
|
||||
if (res.getName().toString().equals(player.getName().toString())){
|
||||
player.sendMessage("DINGDINGDING");
|
||||
townHasRes = true;
|
||||
}
|
||||
}
|
||||
if (!townHasRes){
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.sendMessage("You have left your town boundaries!!!!");
|
||||
module.cbCreatives.remove(player);
|
||||
}
|
||||
}
|
||||
private void debug(Player player, String string){
|
||||
if (player.getName().equalsIgnoreCase("alisolarflare"))
|
||||
player.sendMessage(string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,16 @@ import org.bukkit.GameMode;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import alisolarflare.creativeboundaries.CreativeBoundariesModule;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
|
||||
public class Cbgm0 extends TBMCCommandBase{
|
||||
|
||||
private CreativeBoundariesModule module;
|
||||
|
||||
public Cbgm0(CreativeBoundariesModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) {
|
||||
|
@ -17,6 +24,7 @@ public class Cbgm0 extends TBMCCommandBase{
|
|||
|
||||
Player player = (Player) sender;
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
module.cbCreatives.remove(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue