Anyways, it's time for me to sleep,

This commit is contained in:
alisolarflare 2016-11-30 00:32:04 -05:00
parent 00402bd3a9
commit 6a9004ea13

View file

@ -1,59 +1,14 @@
package alisolarflare.components.creativeboundaries.commands;
import java.util.List;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.creativeboundaries.CreativeBoundariesComponent;
import alisolarflare.components.creativeboundaries.CreativeBoundariesAPI;
public class Cbgm1 extends PlayerCommand {
List<Player> cbCreatives;
public Cbgm1(CreativeBoundariesComponent component) {
this.cbCreatives = component.cbCreatives;
}
@Override
public boolean OnCommand(Player player, String arg2, String[] arg3) {
TownBlock tb = TownyUniverse.getTownBlock(player.getLocation());
if (tb == null) {
player.sendMessage("Some error occured.");
player.sendMessage("TownBlock is null.");
return false;
}
Town town;
try {
town = tb.getTown();
} catch (NotRegisteredException e) {
player.sendMessage("You aren't standing in a town, head to your home town to use this command.");
return false;
}
boolean playerIsInTown = false;
for(Resident res : town.getResidents()){
if (res.getName().toString().equals(player.getName().toString())){
playerIsInTown = true;
break;
}
}
if (!playerIsInTown){
player.sendMessage("Sorry, you're not part of this town");
return false;
}
player.setGameMode(GameMode.CREATIVE);
cbCreatives.add(player);
return true;
return CreativeBoundariesAPI.toCreative(player);
}
@Override
public String[] GetHelpText(String alias){