Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkstyle violations #2624

Merged
merged 3 commits into from
Nov 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions engine/src/main/java/org/terasology/config/PlayerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,22 @@ public void setColor(Color color) {
this.color = color;
}

public Float getHeight() { return height; }
public Float getHeight() {
return height;
}

public void setHeight(Float height) {
this.height = height;
}

public Float getEyeHeight() { return eyeHeight; }
public Float getEyeHeight() {
return eyeHeight;
}

public void setEyeHeight(Float eyeHeight) {
if (eyeHeight< this.height)
if (eyeHeight < this.height) {
this.eyeHeight = eyeHeight;
}
}

private static String defaultPlayerName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public class AffectItemUseCooldownTimeEvent extends AbstractValueModifiableEvent
public AffectItemUseCooldownTimeEvent(float baseValue) {
super(baseValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,7 @@ private void walk(final CharacterMovementComponent movementComp, final Character

movementComp.numberOfJumpsLeft--;
}
}
else {
} else {
if (moveResult.isTopHit() && endVelocity.y > 0) {
endVelocity.y = -0.5f * endVelocity.y;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,24 @@
*/
@API
public interface ConsoleCommand extends Comparable<ConsoleCommand> {
Comparator<ConsoleCommand> COMPARATOR = (o1, o2) -> {
int nameComparison = o1.getName().compareTo(o2.getName());
Comparator<ConsoleCommand> COMPARATOR = new Comparator<ConsoleCommand>() {

if (nameComparison != 0) {
return nameComparison;
}
@Override
public int compare(ConsoleCommand o1, ConsoleCommand o2) {
int nameComparison = o1.getName().compareTo(o2.getName());

if (!o1.endsWithVarargs() && o2.endsWithVarargs()) {
return -1;
} else if (o1.endsWithVarargs() && !o2.endsWithVarargs()) {
return 1;
}
if (nameComparison != 0) {
return nameComparison;
}

return o2.getRequiredParameterCount() - o1.getRequiredParameterCount();
if (!o1.endsWithVarargs() && o2.endsWithVarargs()) {
return -1;
} else if (o1.endsWithVarargs() && !o2.endsWithVarargs()) {
return 1;
}

return o2.getRequiredParameterCount() - o1.getRequiredParameterCount();
};
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,24 @@ public ClientConnectionHandler(JoinStatusImpl joinStatus, NetworkSystemImpl netw
this.moduleManager = CoreRegistry.get(ModuleManager.class);
}

private void scheduleTimeout(Channel inputChannel) {
private void scheduleTimeout(Channel inputChannel) {
channel = inputChannel;
timeoutPoint = System.currentTimeMillis() + timeoutThreshold;
timeoutTimer.schedule(new java.util.TimerTask() {
@Override
public void run() {
synchronized (joinStatus) {
if (System.currentTimeMillis() > timeoutPoint
&& joinStatus.getStatus() != JoinStatus.Status.COMPLETE
&& joinStatus.getStatus() != JoinStatus.Status.FAILED) {
joinStatus.setErrorMessage("Server stopped responding.");
timeoutPoint = System.currentTimeMillis() + timeoutThreshold;
timeoutTimer.schedule(new java.util.TimerTask() {
@Override
public void run() {
synchronized (joinStatus) {
if (System.currentTimeMillis() > timeoutPoint
&& joinStatus.getStatus() != JoinStatus.Status.COMPLETE
&& joinStatus.getStatus() != JoinStatus.Status.FAILED) {
joinStatus.setErrorMessage("Server stopped responding.");
channel.close();
logger.error("Server timeout threshold of {} ms exceeded.", timeoutThreshold);
}
}
}
}, timeoutThreshold + 200);
}
logger.error("Server timeout threshold of {} ms exceeded.", timeoutThreshold);
}
}
}
}, timeoutThreshold + 200);
}

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
Expand All @@ -99,28 +99,29 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
scheduleTimeout(ctx.getChannel());

// Handle message
NetData.NetMessage message = (NetData.NetMessage) e.getMessage();
synchronized (joinStatus) {
timeoutPoint = System.currentTimeMillis() + timeoutThreshold;
if (message.hasServerInfo()) {
receivedServerInfo(ctx, message.getServerInfo());
} else if (message.hasModuleDataHeader()) {
receiveModuleStart(ctx, message.getModuleDataHeader());
} else if (message.hasModuleData()) {
receiveModule(ctx, message.getModuleData());
} else if (message.hasJoinComplete()) {
if (missingModules.size() > 0) {
logger.error(
"The server did not send all of the modules that were needed before ending module transmission.");
}
completeJoin(ctx, message.getJoinComplete());
} else {
logger.error("Received unexpected message");
}
}
}
NetData.NetMessage message = (NetData.NetMessage) e.getMessage();
synchronized (joinStatus) {
timeoutPoint = System.currentTimeMillis() + timeoutThreshold;
if (message.hasServerInfo()) {
receivedServerInfo(ctx, message.getServerInfo());
} else if (message.hasModuleDataHeader()) {
receiveModuleStart(ctx, message.getModuleDataHeader());
} else if (message.hasModuleData()) {
receiveModule(ctx, message.getModuleData());
} else if (message.hasJoinComplete()) {
if (missingModules.size() > 0) {
logger.error(
"The server did not send all of the modules that were needed before ending module transmission.");
}
completeJoin(ctx, message.getJoinComplete());
} else {
logger.error("Received unexpected message");
}
}
}

private void receiveModuleStart(ChannelHandlerContext channelHandlerContext, NetData.ModuleDataHeader moduleDataHeader) {
private void receiveModuleStart(ChannelHandlerContext channelHandlerContext,
NetData.ModuleDataHeader moduleDataHeader) {
if (receivingModule != null) {
joinStatus.setErrorMessage("Module download error");
channelHandlerContext.getChannel().close();
Expand All @@ -133,24 +134,27 @@ private void receiveModuleStart(ChannelHandlerContext channelHandlerContext, Net
channelHandlerContext.getChannel().close();
} else {
String sizeString = getSizeString(moduleDataHeader.getSize());
joinStatus.setCurrentActivity("Downloading " + moduleDataHeader.getId() + ":" + moduleDataHeader.getVersion() + " (" + sizeString + ","
+ missingModules.size() + " modules remain)");
logger.info("Downloading " + moduleDataHeader.getId() + ":" + moduleDataHeader.getVersion() + " (" + sizeString + ","
+ missingModules.size() + " modules remain)");
joinStatus.setCurrentActivity(
"Downloading " + moduleDataHeader.getId() + ":" + moduleDataHeader.getVersion() + " ("
+ sizeString + "," + missingModules.size() + " modules remain)");
logger.info("Downloading " + moduleDataHeader.getId() + ":" + moduleDataHeader.getVersion() + " ("
+ sizeString + "," + missingModules.size() + " modules remain)");
receivingModule = moduleDataHeader;
lengthReceived = 0;
try {
tempModuleLocation = Files.createTempFile("terasologyDownload", ".tmp");
tempModuleLocation.toFile().deleteOnExit();
downloadingModule = new BufferedOutputStream(Files.newOutputStream(tempModuleLocation, StandardOpenOption.WRITE));
downloadingModule = new BufferedOutputStream(
Files.newOutputStream(tempModuleLocation, StandardOpenOption.WRITE));
} catch (IOException e) {
logger.error("Failed to write received module", e);
joinStatus.setErrorMessage("Module download error");
channelHandlerContext.getChannel().close();
}
}
} else {
logger.error("Received unwanted module {}:{} from server", moduleDataHeader.getId(), moduleDataHeader.getVersion());
logger.error("Received unwanted module {}:{} from server", moduleDataHeader.getId(),
moduleDataHeader.getVersion());
joinStatus.setErrorMessage("Module download error");
channelHandlerContext.getChannel().close();
}
Expand Down Expand Up @@ -230,7 +234,8 @@ private void receivedServerInfo(ChannelHandlerContext channelHandlerContext, Net

// Request missing modules
for (NetData.ModuleInfo info : message.getModuleList()) {
if (null == moduleManager.getRegistry().getModule(new Name(info.getModuleId()), new Version(info.getModuleVersion()))) {
if (null == moduleManager.getRegistry().getModule(new Name(info.getModuleId()),
new Version(info.getModuleVersion()))) {
missingModules.add(info.getModuleId().toLowerCase(Locale.ENGLISH));
}
}
Expand Down Expand Up @@ -260,9 +265,9 @@ private void sendJoin(ChannelHandlerContext channelHandlerContext) {
channelHandlerContext.getChannel().write(NetData.NetMessage.newBuilder().setJoin(bldr).build());
}

public JoinStatus getJoinStatus() {
synchronized (joinStatus) {
return joinStatus;
}
}
public JoinStatus getJoinStatus() {
synchronized (joinStatus) {
return joinStatus;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ public void setSource(AssetDataFile source) {
public AssetDataFile getSource() {
return source;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ public UIWidget getRootWidget() {
public AssetDataFile getSource() {
return source;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ public E getObject() {
public String toString() {
return name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ List<AbstractContextMenuItem> getOptions() {
return this.options;
}

public <E> void addOption(String name, Consumer<E> consumer, E item) {
options.add(new ContextMenuOption<E>(name, consumer, item, true));
public <E> void addOption(String optionName, Consumer<E> consumer, E item) {
options.add(new ContextMenuOption<E>(optionName, consumer, item, true));
}

public void addSubmenu(MenuTree tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public ToStringTextRenderer(TranslationSystem translationSystemInput) {
public String getString(T value) {
if (translationSystem == null) {
return Objects.toString(value);
}
else {
} else {
return translationSystem.translate(Objects.toString(value));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ public String get() {
}

final UILabel saveGamePath = find("saveGamePath", UILabel.class);
if(saveGamePath != null)
{
saveGamePath.setText(translationSystem.translate("${engine:menu#save-game-path} ")+PathManager.getInstance().getSavesPath().toAbsolutePath().toString());
if(saveGamePath != null) {
saveGamePath.setText(
translationSystem.translate("${engine:menu#save-game-path} ") +
PathManager.getInstance().getSavesPath().toAbsolutePath().toString());
}

final UIList<GameInfo> gameList = find("gameList", UIList.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public class PlayerSettingsScreen extends CoreScreenLayer {
private final List<Color> colors = CieCamColors.L65C65;

private UIText nametext;
private UISlider slider, heightSlider, eyeHeightSlider;
private UISlider slider;
private UISlider heightSlider;
private UISlider eyeHeightSlider;
private UIImage img;
private UIDropdownScrollable<Locale> language;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) {

@Override
public String getMode() {
if (!isEnabled())
if (!isEnabled()) {
return DISABLED_MODE;
}

if (active) {
return ACTIVE_MODE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

/* Interface intended to be front-facing to user for controller interaction. */
public interface ControllerListener {
public final int LEFT_CONTROLLER = 0;
public final int RIGHT_CONTROLLER = 1;
public static int k_EAxis_Trigger = 1;
public static int k_EAxis_TouchPad = 0;
public static long k_buttonTouchpad = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_SteamVR_Touchpad);
public static long k_buttonTrigger = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_SteamVR_Trigger);
public static long k_buttonAppMenu = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_ApplicationMenu);
public static long k_buttonGrip = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_Grip);
public static float triggerThreshold = .25f;
int LEFT_CONTROLLER = 0;
int RIGHT_CONTROLLER = 1;
int EAXIS_TRIGGER = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance these names are made to match naming in another place, like the VR provider itself?

@indianajohn - ping! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I'd suggest adding the SuppressionWarnings module to the checkstyle.xml and add a @SuppressWarnings annotation to the class.

int EAXIS_TOUCHPAD = 0;
long BUTTON_TOUCHPAD = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_SteamVR_Touchpad);
long BUTTON_TRIGGER = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_SteamVR_Trigger);
long BUTTON_APP_MENU = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_ApplicationMenu);
long BUTTON_GRIP = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_Grip);
float TRIGGER_THRESHOLD = .25f;

public void buttonStateChanged(VRControllerState_t stateBefore, VRControllerState_t stateAfter, int nController);
void buttonStateChanged(VRControllerState_t stateBefore, VRControllerState_t stateAfter, int nController);
// TODO: touch, axes
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import org.terasology.world.liquid.LiquidData;

import java.text.DecimalFormat;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
* Chunks are the basic components of the world. Each chunk contains a fixed amount of blocks
Expand Down Expand Up @@ -81,8 +79,6 @@ public class ChunkImpl implements Chunk {
private AABB aabb;
private Region3i region;

private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();

private boolean disposed;
private boolean ready;
private volatile boolean dirty;
Expand Down Expand Up @@ -445,6 +441,14 @@ public int hashCode() {
return Objects.hashCode(chunkPos);
}

@Override
public boolean equals(Object obj) {
// According to hashCode() two ChunkImpls are not equal when their
// position differs. The default equals() compares object instances.
// The same instance has the same chunkPos, so this is valid.
return super.equals(obj);
}

@Override
public void setMesh(ChunkMesh mesh) {
this.activeMesh = mesh;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.terasology.core.debug;

/**
* Describes an instance of a benchmark which can be run.
*
* <p>The reason for not simply using the {@link Runnable} interface is that we
* may need something like a {@code prepareStep()} or {@code cleanupStep()}
* method, which must not be measured, in the future.</p>
*/
abstract class AbstractBenchmarkInstance {

public abstract void runStep();
}
Loading