Removed extra fastLighting flag.

Fast lighting is now used when available.
This commit is contained in:
TomyLobo 2011-10-31 02:59:12 +01:00
parent d3822ee345
commit 6b0f237a46
5 changed files with 18 additions and 88 deletions

View File

@ -100,11 +100,6 @@ public class EditSession {
*/
private boolean fastMode = false;
/**
* Use fast lighting as well if using fast mode.
*/
private boolean fastLighting = false;
/**
* Block bag to use for getting blocks.
*/
@ -214,13 +209,13 @@ public class EditSession {
if (BlockType.usesData(type)) {
if (fastMode) {
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0, fastLighting);
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0);
} else {
result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0);
}
} else {
if (fastMode) {
result = world.setBlockTypeFast(pt, type, fastLighting);
result = world.setBlockTypeFast(pt, type);
} else {
result = world.setBlockType(pt, type);
}
@ -532,24 +527,6 @@ public class EditSession {
queued = false;
}
/**
* Set fast lighting.
*
* @param fastLighting
*/
public void setFastLighting(boolean fastLighting) {
this.fastLighting = fastLighting;
}
/**
* Return fast lighting status.
*
* @return
*/
public boolean hasFastLighting() {
return fastLighting;
}
/**
* Set fast mode.
*

View File

@ -73,7 +73,6 @@ public class LocalSession {
private boolean beenToldVersion = false;
private boolean hasCUISupport = false;
private boolean fastMode = false;
private boolean fastLighting = false;
private Mask mask;
private TimeZone timezone = TimeZone.getDefault();
private Boolean jumptoBlock = true;
@ -645,7 +644,6 @@ public class LocalSession {
new EditSession(player.getWorld(),
getBlockChangeLimit(), blockBag);
editSession.setFastMode(fastMode);
editSession.setFastLighting(fastLighting);
editSession.setMask(mask);
return editSession;
@ -669,24 +667,6 @@ public class LocalSession {
this.fastMode = fastMode;
}
/**
* Checks if the session has fast lighting enabled.
*
* @return
*/
public boolean hasFastLighting() {
return fastLighting;
}
/**
* Set fast lighting.
*
* @param fastLighting
*/
public void setFastLighting(boolean fastLighting) {
this.fastLighting = fastLighting;
}
/**
* Get the mask.
*

View File

@ -63,10 +63,6 @@ public abstract class LocalWorld {
return setBlockType(pt, type);
}
public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) {
return setBlockTypeFast(pt, type);
}
/**
* Get block type.
*
@ -118,10 +114,6 @@ public abstract class LocalWorld {
return ret;
}
public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) {
return setTypeIdAndDataFast(pt, type, data);
}
/**
* Get block data.
*

View File

@ -111,21 +111,8 @@ public class BukkitWorld extends LocalWorld {
*/
@Override
public boolean setBlockTypeFast(Vector pt, int type) {
return setBlockTypeFast(pt, type, false);
}
/**
* Set block type.
*
* @param pt
* @param type
* @param fastLighting
* @return
*/
@Override
public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable && fastLighting) {
if (fastLightingAvailable) {
type = type & 255;
final int previousOpacity = Block_lightOpacity[type];
Block_lightOpacity[type] = 0;
@ -158,13 +145,8 @@ public class BukkitWorld extends LocalWorld {
*/
@Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data){
return setTypeIdAndDataFast(pt, type, data, false);
}
@Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable && fastLighting) {
if (fastLightingAvailable) {
type = type & 255;
final int previousOpacity = Block_lightOpacity[type];
Block_lightOpacity[type] = 0;

View File

@ -63,7 +63,6 @@ public class GeneralCommands {
@Command(
aliases = { "/fast" },
flags = "l",
usage = "[on|off]",
desc = "Toggle fast mode",
min = 0,
@ -74,24 +73,24 @@ public class GeneralCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
boolean light = args.hasFlag('f');
String newState = args.getString(0, null);
Boolean dir = newState == null ? null : newState.equals("on") ? true : newState.equals("off") ? false : null;
if (session.hasFastMode()) {
if ("on".equals(newState)) {
player.printError("Fast mode already enabled.");
return;
}
boolean hadFast = session.hasFastMode();
boolean hadLight = session.hasFastLighting();
session.setFastMode(false);
player.print("Fast mode disabled.");
} else {
if ("off".equals(newState)) {
player.printError("Fast mode already disabled.");
return;
}
boolean setFast = dir == null ? !hadFast : dir;
boolean setLight = dir == null ? !hadLight : dir;
session.setFastMode(setFast);
if (light) {
session.setFastLighting(setLight);
session.setFastMode(true);
player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
}
player.print("Fast mode " + (setFast == hadFast ? "already " : "") + (!setFast ? "disabled." :
("enabled. You may need to rejoin to see changes"
+ (setLight ? "and lighting in affected chunks may be wrong." : "."))));
}
@Command(