disco floor size limit, stained glass floor, fixes
This commit is contained in:
parent
ad787729ba
commit
487a735264
@ -28,12 +28,12 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class DiscoParty {
|
||||
|
||||
// Static properties
|
||||
static int defaultDuration = 300; // ticks for entire party
|
||||
static int defaultPeriod = 10; // ticks per state change
|
||||
static int defaultRadius = 5;
|
||||
static int defaultSheep = 10;
|
||||
static float defaultSheepJump = 0.35f;
|
||||
static int maxFloorSize = 5;
|
||||
static int maxDuration = 2400; // 120 seconds
|
||||
static int maxSheep = 100;
|
||||
static int maxRadius = 100;
|
||||
@ -304,12 +304,12 @@ public class DiscoParty {
|
||||
|
||||
void spawnFloor(World world, Location loc) {
|
||||
// First we'll save the floor state
|
||||
for (int x = loc.getBlockX() - this.radius; x < loc.getX() + this.radius; ++x) {
|
||||
for (int z = loc.getBlockZ() - this.radius; z < loc.getZ() + this.radius; ++z) {
|
||||
for (int x = loc.getBlockX() - Math.min(this.radius, DiscoParty.maxFloorSize); x < loc.getX() + Math.min(this.radius, DiscoParty.maxFloorSize); ++x) {
|
||||
for (int z = loc.getBlockZ() - Math.min(this.radius, DiscoParty.maxFloorSize); z < loc.getZ() + Math.min(this.radius, DiscoParty.maxFloorSize); ++z) {
|
||||
Block block = world.getBlockAt(x, loc.getBlockY(), z);
|
||||
if (block.getType() != Material.WOOL) {
|
||||
if (block.getType() != Material.STAINED_GLASS) {
|
||||
this.getFloorCache().add(block.getState());
|
||||
block.setType(Material.WOOL);
|
||||
block.setType(Material.STAINED_GLASS);
|
||||
this.getFloorBlocks().add(block);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
|
||||
private static DiscoSheep instance;
|
||||
|
||||
static boolean partyOnJoin = false;
|
||||
boolean partyOnJoin = true;
|
||||
Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
|
||||
private CommandsManager<CommandSender> commands;
|
||||
|
||||
@ -92,6 +92,7 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
getConfig().addDefault("default.radius", DiscoParty.defaultRadius);
|
||||
getConfig().addDefault("default.duration", toSeconds_i(DiscoParty.defaultDuration));
|
||||
getConfig().addDefault("default.period-ticks", DiscoParty.defaultPeriod);
|
||||
getConfig().addDefault("max.floor_size", DiscoParty.maxFloorSize);
|
||||
|
||||
/*
|
||||
* Iterate through all live entities and create default configuration values for them
|
||||
@ -123,6 +124,7 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
DiscoParty.defaultRadius = getConfig().getInt("default.radius");
|
||||
DiscoParty.defaultDuration = toTicks(getConfig().getInt("default.duration"));
|
||||
DiscoParty.defaultPeriod = getConfig().getInt("default.period-ticks");
|
||||
DiscoParty.maxFloorSize = getConfig().getInt("max.floor_size");
|
||||
|
||||
for (String key : getConfig().getConfigurationSection("default.guests").getKeys(false)) {
|
||||
DiscoParty.getDefaultGuestNumbers().put(key, getConfig().getInt("default.guests." + key));
|
||||
@ -199,8 +201,8 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
}
|
||||
|
||||
public boolean toggleOnJoin() {
|
||||
DiscoSheep.partyOnJoin = !DiscoSheep.partyOnJoin;
|
||||
return DiscoSheep.partyOnJoin;
|
||||
partyOnJoin = !partyOnJoin;
|
||||
return partyOnJoin;
|
||||
}
|
||||
|
||||
public void removeParty(String name) {
|
||||
@ -209,135 +211,6 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/*-- Actual commands begin here --*/
|
||||
/*boolean helpCommand(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW
|
||||
+ "DiscoSheep Help\n"
|
||||
+ ChatColor.GRAY
|
||||
+ " Subcommands\n"
|
||||
+ ChatColor.WHITE + "me, stop, all, stopall, save, reload, togglejoin\n"
|
||||
+ "other <players>: start a party for the space-delimited list of players\n"
|
||||
+ "defaults: Change the default settings for parties (takes normal arguments)\n"
|
||||
+ ChatColor.GRAY + " Arguments\n"
|
||||
+ ChatColor.WHITE + "-n <integer>: set the number of sheep per player that spawn\n"
|
||||
+ "-t <integer>: set the party duration in seconds\n"
|
||||
+ "-p <ticks>: set the number of ticks between each disco beat\n"
|
||||
+ "-r <integer>: set radius of the area in which sheep can spawn\n"
|
||||
//+ "-g <mob> <number>: set spawns for other mobs\n"
|
||||
+ "-l: enables lightning\n"
|
||||
+ "-fw: enables fireworks");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean stopMeCommand(CommandSender sender) {
|
||||
stopParty(sender.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean stopAllCommand(CommandSender sender) {
|
||||
if (sender.hasPermission(PERMISSION_STOPALL)) {
|
||||
stopAllParties();
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_STOPALL);
|
||||
}
|
||||
}
|
||||
|
||||
boolean partyCommand(Player player, DiscoParty party) {
|
||||
if (player.hasPermission(PERMISSION_PARTY)) {
|
||||
if (!hasParty(player.getName())) {
|
||||
party.setPlayer(player);
|
||||
party.startDisco();
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "You already have a party. Are you underground?");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(player, PERMISSION_PARTY);
|
||||
}
|
||||
}
|
||||
|
||||
boolean reloadCommand(CommandSender sender) {
|
||||
if (sender.hasPermission(PERMISSION_RELOAD)) {
|
||||
reloadConfigFromDisk();
|
||||
sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk");
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_RELOAD);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
// UUIDs not necessary since DiscoSheep only lasts for one session at most
|
||||
// and permissions will handle onJoin DiscoSheep
|
||||
boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) {
|
||||
if (sender.hasPermission(PERMISSION_OTHER)) {
|
||||
Player p;
|
||||
for (String playerName : players) {
|
||||
p = Bukkit.getServer().getPlayer(playerName);
|
||||
if (p != null) {
|
||||
if (!hasParty(p.getName())) {
|
||||
DiscoParty individualParty = party.clone(p);
|
||||
individualParty.startDisco();
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("Invalid player: " + playerName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_OTHER);
|
||||
}
|
||||
}
|
||||
|
||||
boolean partyAllCommand(CommandSender sender, DiscoParty party) {
|
||||
if (sender.hasPermission(PERMISSION_ALL)) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (!hasParty(p.getName())) {
|
||||
DiscoParty individualParty = party.clone(p);
|
||||
individualParty.startDisco();
|
||||
p.sendMessage(ChatColor.RED + "LET'S DISCO!!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
boolean togglePartyOnJoinCommand(CommandSender sender) {
|
||||
if (!sender.hasPermission(PERMISSION_TOGGLEPARTYONJOIN)) {
|
||||
return noPermsMessage(sender, PERMISSION_TOGGLEPARTYONJOIN);
|
||||
}
|
||||
partyOnJoin = !partyOnJoin;
|
||||
if (partyOnJoin) {
|
||||
sender.sendMessage(ChatColor.GREEN + "DiscoSheep party on join functionality enabled.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + "DiscoSheep party on join functionality disabled.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean setDefaultsCommand(CommandSender sender, DiscoParty party) {
|
||||
if (sender.hasPermission(PERMISSION_CHANGEDEFAULTS)) {
|
||||
party.setDefaultsFromCurrent();
|
||||
sender.sendMessage(ChatColor.GREEN + "DiscoSheep configured with new defaults (not saved to disk yet)");
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_CHANGEDEFAULTS);
|
||||
}
|
||||
}
|
||||
|
||||
boolean saveConfigCommand(CommandSender sender) {
|
||||
if (sender.hasPermission(PERMISSION_SAVECONFIG)) {
|
||||
saveConfigToDisk();
|
||||
sender.sendMessage(ChatColor.GREEN + "DiscoSheep config saved to disk");
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_SAVECONFIG);
|
||||
}
|
||||
|
||||
}*/
|
||||
void partyOnJoin(Player player) {
|
||||
if (!partyOnJoin) {
|
||||
return;
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Sheep;
|
||||
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.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
@ -78,5 +79,11 @@ public class PartyEvents implements Listener {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// prevent disco floor breaking
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreakEvent(BlockBreakEvent e) {
|
||||
if (party.getFloorBlocks().contains(e.getBlock())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user