Code-Style

This commit is contained in:
Tim Düsterhus 2011-09-10 17:49:12 +02:00
parent bcfa109944
commit 8788c9c4b6
28 changed files with 116 additions and 107 deletions

View File

@ -31,7 +31,7 @@ import com.tommytony.war.utils.*;
/**
* Main class of War
*
*
* @author tommytony, Tim Düsterhus
* @package bukkit.tommytony.war
*/
@ -164,7 +164,7 @@ public class War extends JavaPlugin {
}
this.getServer().getScheduler().cancelTasks(this);
this.log("War v" + this.desc.getVersion() + " is off.", Level.INFO);
this.setLoaded(false);
}
@ -192,7 +192,7 @@ public class War extends JavaPlugin {
/**
* Converts the player-inventory to a loadout hashmap
*
*
* @param inv
* inventory to get the items from
* @param loadout
@ -221,7 +221,7 @@ public class War extends JavaPlugin {
/**
* Converts the player-inventory to a loadout hashmap
*
*
* @param player
* player to get the inventory to get the items from
* @param loadout
@ -497,7 +497,7 @@ public class War extends JavaPlugin {
/**
* Colors the teams and examples in messages
*
*
* @param String
* str message-string
* @param String
@ -514,7 +514,7 @@ public class War extends JavaPlugin {
/**
* Logs a specified message with a specified level
*
*
* @param String
* str message to log
* @param Level
@ -866,7 +866,7 @@ public class War extends JavaPlugin {
}
public TeamSpawnStyle getDefaultSpawnStyle() {
return defaultSpawnStyle;
return this.defaultSpawnStyle;
}
public void setDefaultSpawnStyle(TeamSpawnStyle defaultSpawnStyle) {
@ -878,7 +878,7 @@ public class War extends JavaPlugin {
}
public FlagReturn getDefaultFlagReturn() {
return defaultFlagReturn;
return this.defaultFlagReturn;
}
public HashMap<String, InventoryStash> getDisconnected() {

View File

@ -19,9 +19,9 @@ import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
/**
*
*
* @author tommytony
*
*
*/
public class WarBlockListener extends BlockListener {
@ -187,7 +187,7 @@ public class WarBlockListener extends BlockListener {
if (warzone.getFlagReturn() == FlagReturn.FLAG || warzone.getFlagReturn() == FlagReturn.SPAWN) {
spawnOrFlag = warzone.getFlagReturn().toString();
}
for (Team t : warzone.getTeams()) {
t.teamcast(team.getKind().getColor() + player.getName() + ChatColor.WHITE + " stole team " + lostFlagTeam.getName() + "'s flag.");
if (t.getName().equals(lostFlagTeam.getName())) {
@ -195,8 +195,8 @@ public class WarBlockListener extends BlockListener {
+ " from reaching team " + team.getName() + "'s " + spawnOrFlag + ".");
}
}
War.war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team " + spawnOrFlag + " to capture it!");
} else {
War.war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team.");

View File

@ -9,7 +9,7 @@ import bukkit.tommytony.war.command.*;
/**
* Handles commands received by War
*
*
* @author Tim Düsterhus
* @package bukkit.tommytony.war
*/
@ -17,7 +17,7 @@ public class WarCommandHandler {
/**
* Handles a command
*
*
* @param sender
* The sender of the command
* @param cmd

View File

@ -25,7 +25,7 @@ import com.tommytony.war.Warzone;
/**
* Handles Entity-Events
*
*
* @author tommytony, Tim Düsterhus
* @package bukkit.tommytony.war
*/
@ -33,7 +33,7 @@ public class WarEntityListener extends EntityListener {
/**
* Handles PVP-Damage
*
*
* @param event
* fired event
*/
@ -133,7 +133,7 @@ public class WarEntityListener extends EntityListener {
/**
* Protects important structures from explosions
*
*
* @see EntityListener.onEntityExplode()
*/
@Override
@ -166,7 +166,7 @@ public class WarEntityListener extends EntityListener {
/**
* Handles damage on Players
*
*
* @see EntityListener.onEntityDamage()
*/
@Override
@ -227,7 +227,7 @@ public class WarEntityListener extends EntityListener {
/**
* Prevents creatures from spawning in warzones if no creatures is active
*
*
* @see EntityListener.onCreatureSpawn()
*/
@Override
@ -246,7 +246,7 @@ public class WarEntityListener extends EntityListener {
/**
* Prevents health regaining caused by peaceful mode
*
*
* @see EntityListener.onEntityRegainHealth()
*/
@Override
@ -254,7 +254,7 @@ public class WarEntityListener extends EntityListener {
if (!War.war.isLoaded() || event.getRegainReason() != RegainReason.REGEN) {
return;
}
Entity entity = event.getEntity();
if (!(entity instanceof Player)) {
return;

View File

@ -37,7 +37,7 @@ public class WarPlayerListener extends PlayerListener {
/**
* Correctly removes quitting players from warzones
*
*
* @see PlayerListener.onPlayerQuit()
*/
@Override
@ -376,7 +376,9 @@ public class WarPlayerListener extends PlayerListener {
boolean inFlag = (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation()));
if (playerWarzone.getFlagReturn() == FlagReturn.BOTH) {
if (!inSpawn && !inFlag) return;
if (!inSpawn && !inFlag) {
return;
}
} else if (playerWarzone.getFlagReturn() == FlagReturn.SPAWN) {
if (inFlag) {
War.war.badMsg(player, "You have to capture the enemy flag at your team's spawn.");

View File

@ -11,7 +11,7 @@ import com.tommytony.war.Warzone;
/**
* Lists all warzones
*
*
* @author Tim Düsterhus
*/
public class WarzonesCommand extends AbstractWarCommand {

View File

@ -4,7 +4,7 @@ public enum FlagReturn {
BOTH,
FLAG,
SPAWN;
@Override
public String toString() {
return super.toString().toLowerCase();

View File

@ -8,9 +8,9 @@ import org.bukkit.block.BlockFace;
import com.tommytony.war.volumes.Volume;
/**
*
*
* @author tommytony
*
*
*/
public class Monument {
private Location location;

View File

@ -15,9 +15,9 @@ import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.Volume;
/**
*
*
* @author tommytony
*
*
*/
public class Team {
private List<Player> players = new ArrayList<Player>();

View File

@ -52,6 +52,7 @@ public enum TeamKind {
return this.material;
}
@Override
public String toString() {
return super.toString().toLowerCase();
}

View File

@ -15,7 +15,7 @@ import com.tommytony.war.volumes.BlockInfo;
import com.tommytony.war.volumes.Volume;
/**
*
*
* @author tommytony, Tim Düsterhus
* @package com.tommytony.war
*/
@ -192,7 +192,7 @@ public class WarHub {
/**
* Resets the sign of the given warzone
*
*
* @param Warzone
* zone
*/

View File

@ -265,9 +265,13 @@ public class Warzone {
// nom drops
for(Entity entity : (this.getWorld().getEntities())) {
if (!(entity instanceof Item) && !(entity instanceof CraftItem)) continue;
if (!(entity instanceof Item) && !(entity instanceof CraftItem)) {
continue;
}
// validate position
if (!this.getVolume().contains(entity.getLocation())) continue;
if (!this.getVolume().contains(entity.getLocation())) {
continue;
}
// omnomnomnom
entity.remove();

View File

@ -18,9 +18,9 @@ import com.tommytony.war.volumes.Volume;
import com.tommytony.war.volumes.ZoneVolume;
/**
*
*
* @author tommytony
*
*
*/
public class ZoneLobby {
private final Warzone warzone;
@ -41,7 +41,7 @@ public class ZoneLobby {
/**
* Use this constructor with /setzonelobby <n/s/e/w>
*
*
* @param war
* @param warzone
* @param wall
@ -59,7 +59,7 @@ public class ZoneLobby {
/**
* Use this constructor with /setzonelobby <zonename>. Makes sure the lobby is not sticking inside the zone.
*
*
* @param war
* @param warzone
* @param wall
@ -115,7 +115,7 @@ public class ZoneLobby {
/**
* Changes the lobby's position. Orientation is determined from the player location. Creates volume or resets. Saves new lobby blocks.
*
*
* @param playerLocation
*/
public void setLocation(Location playerLocation) {
@ -174,7 +174,7 @@ public class ZoneLobby {
/**
* Classic way of creating a lobby. Lobby position goes to middle of zone wall. Creates volume or resets. Saves new lobby blocks.
*
*
* @param newWall
*/
public void setWall(BlockFace newWall) {

View File

@ -14,9 +14,9 @@ import com.tommytony.war.volumes.BlockInfo;
import bukkit.tommytony.war.War;
/**
*
*
* @author tommytony
*
*
*/
public class ZoneWallGuard {
private Player player;

View File

@ -23,7 +23,9 @@ public class HelmetProtectionTask implements Runnable {
* @see Runnable.run()
*/
public void run() {
if (!War.war.isLoaded()) return;
if (!War.war.isLoaded()) {
return;
}
for (Warzone zone : War.war.getWarzones()) {
for (Team team : zone.getTeams()) {
for (Player player : team.getPlayers()) {
@ -33,7 +35,7 @@ public class HelmetProtectionTask implements Runnable {
teamBlockMaterial = team.getKind().getMaterial();
// 1) Replace missing block head
if (playerInv.getHelmet().getType() != teamBlockMaterial) {
playerInv.setHelmet(createBlockHead(team));
playerInv.setHelmet(this.createBlockHead(team));
}
// 2) Get rid of extra blocks in inventory: only keep one
HashMap<Integer, ? extends ItemStack> blocks = playerInv.all(teamBlockMaterial);
@ -48,7 +50,7 @@ public class HelmetProtectionTask implements Runnable {
}
i++;
}
playerInv.setItem(playerInv.firstEmpty(), createBlockHead(team));
playerInv.setItem(playerInv.firstEmpty(), this.createBlockHead(team));
if (removed > 1) {
War.war.badMsg(player, "All that " + team.getName() + " wool must have been heavy!");
}

View File

@ -20,7 +20,7 @@ public class LoadoutResetJob implements Runnable {
public void run() {
this.zone.resetInventory(this.team, this.player);
// Stop fire here, since doing it in the same tick as death doesn't extinguish it
player.setFireTicks(0);
this.player.setFireTicks(0);
}
}

View File

@ -30,9 +30,9 @@ import com.tommytony.war.volumes.ZoneVolume;
/**
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
*
*
* @author tommytony
*
*
*/
public class PreDeGaulleZoneVolumeMapper {

View File

@ -10,7 +10,7 @@ import java.util.Properties;
/**
* Used for accessing and creating .[properties] files, reads them as utf-8, saves as utf-8. Internationalization is key importance especially for character codes.
*
*
* @author Nijikokun
* @version 1.0.4, %G%
*/
@ -27,7 +27,7 @@ public final class PropertiesFile {
/**
* Creates or opens a properties file using specified filename
*
*
* @param fileName
*/
public PropertiesFile(String fileName) {
@ -48,7 +48,7 @@ public final class PropertiesFile {
/**
* The loader for property files, it reads the file as UTF8 or converts the string into UTF8. Used for simple runthrough's, loading, or reloading of the file.
*
*
* @throws IOException
*/
public void load() throws IOException {
@ -88,20 +88,20 @@ public final class PropertiesFile {
* Returns a Map of all <code>key=value</code> properties in the file as <code>&lt;key (java.lang.String), value (java.lang.String)></code> <br />
* <br />
* Example: <blockquote>
*
*
* <pre>
* PropertiesFile settings = new PropertiesFile(&quot;settings.properties&quot;);
* Map&lt;String, String&gt; mappedSettings;
*
*
* try {
* mappedSettings = settings.returnMap();
* } catch (Exception ex) {
* log.info(&quot;Failed mapping settings.properties&quot;);
* }
* </pre>
*
*
* </blockquote>
*
*
* @return <code>map</code> - Simple Map HashMap of the entire <code>key=value</code> as <code>&lt;key (java.lang.String), value (java.lang.String)></code>
* @throws Exception
* If the properties file doesn't exist.
@ -113,7 +113,7 @@ public final class PropertiesFile {
/**
* Checks to see if the .[properties] file contains the given <code>key</code>.
*
*
* @param var
* The key we are going to be checking the existance of.
* @return <code>Boolean</code> - True if the <code>key</code> exists, false if it cannot be found.
@ -124,7 +124,7 @@ public final class PropertiesFile {
/**
* Checks to see if this <code>key</code> exists in the .[properties] file.
*
*
* @param var
* The key we are grabbing the value of.
* @return <code>java.lang.String</code> - True if the <code>key</code> exists, false if it cannot be found.
@ -135,7 +135,7 @@ public final class PropertiesFile {
/**
* Remove a key from the file if it exists. This will save() which will invoke a load() on the file.
*
*
* @see #save()
* @param var
* The <code>key</code> that will be removed from the file
@ -149,7 +149,7 @@ public final class PropertiesFile {
/**
* Checks the existance of a <code>key</code>.
*
*
* @see #containsKey(java.lang.String)
* @param key
* The <code>key</code> in question of existance.
@ -161,7 +161,7 @@ public final class PropertiesFile {
/**
* Returns the value of the <code>key</code> given as a <code>String</code>, however we do not set a string if no <code>key</code> is found.
*
*
* @see #getProperty(java.lang.String)
* @param key
* The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to "" or empty.
@ -176,7 +176,7 @@ public final class PropertiesFile {
/**
* Returns the value of the <code>key</code> given as a <code>String</code>. If it is not found, it will invoke saving the default <code>value</code> to the properties file.
*
*
* @see #setString(java.lang.String, java.lang.String)
* @see #getProperty(java.lang.String)
* @param key
@ -196,7 +196,7 @@ public final class PropertiesFile {
/**
* Save the value given as a <code>String</code> on the specified key.
*
*
* @see #save()
* @param key
* The <code>key</code> that we will be addressing the <code>value</code> to.
@ -210,7 +210,7 @@ public final class PropertiesFile {
/**
* Returns the value of the <code>key</code> given in a Integer, however we do not set a string if no <code>key</code> is found.
*
*
* @see #getProperty(String var)
* @param key
* The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0
@ -225,7 +225,7 @@ public final class PropertiesFile {
/**
* Returns the int value of a key
*
*
* @see #setInt(String key, int value)
* @param key
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
@ -245,7 +245,7 @@ public final class PropertiesFile {
/**
* Save the value given as a <code>int</code> on the specified key.
*
*
* @see #save()
* @param key
* The <code>key</code> that we will be addressing the <code>value</code> to.
@ -260,7 +260,7 @@ public final class PropertiesFile {
/**
* Returns the value of the <code>key</code> given in a Double, however we do not set a string if no <code>key</code> is found.
*
*
* @see #getProperty(String var)
* @param key
* The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0.0
@ -275,7 +275,7 @@ public final class PropertiesFile {
/**
* Returns the double value of a key
*
*
* @see #setDouble(String key, double value)
* @param key
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
@ -294,7 +294,7 @@ public final class PropertiesFile {
/**
* Save the value given as a <code>double</code> on the specified key.
*
*
* @see #save()
* @param key
* The <code>key</code> that we will be addressing the <code>value</code> to.
@ -309,7 +309,7 @@ public final class PropertiesFile {
/**
* Returns the value of the <code>key</code> given in a Long, however we do not set a string if no <code>key</code> is found.
*
*
* @see #getProperty(String var)
* @param key
* The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0L
@ -324,7 +324,7 @@ public final class PropertiesFile {
/**
* Returns the long value of a key
*
*
* @see #setLong(String key, long value)
* @param key
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
@ -343,7 +343,7 @@ public final class PropertiesFile {
/**
* Save the value given as a <code>long</code> on the specified key.
*
*
* @see #save()
* @param key
* The <code>key</code> that we will be addressing the <code>value</code> to.
@ -358,7 +358,7 @@ public final class PropertiesFile {
/**
* Returns the value of the <code>key</code> given in a Boolean, however we do not set a string if no <code>key</code> is found.
*
*
* @see #getProperty(String var)
* @param key
* The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to false
@ -373,7 +373,7 @@ public final class PropertiesFile {
/**
* Returns the boolean value of a key
*
*
* @see #setBoolean(String key, boolean value)
* @param key
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
@ -392,7 +392,7 @@ public final class PropertiesFile {
/**
* Save the value given as a <code>boolean</code> on the specified key.
*
*
* @see #save()
* @param key
* The <code>key</code> that we will be addressing the <code>value</code> to.

View File

@ -20,9 +20,9 @@ import bukkit.tommytony.war.War;
import com.tommytony.war.volumes.Volume;
/**
*
*
* @author tommytony
*
*
*/
public class VolumeMapper {

View File

@ -17,9 +17,9 @@ import com.tommytony.war.jobs.RestoreWarhubJob;
import com.tommytony.war.jobs.RestoreWarzonesJob;
/**
*
*
* @author tommytony
*
*
*/
public class WarMapper {
@ -239,7 +239,7 @@ public class WarMapper {
// spawnStyle
warConfig.setString("flagReturn", War.war.getDefaultFlagReturn().toString());
// defaultReward
String defaultRewardStr = "";
HashMap<Integer, ItemStack> rewardItems = War.war.getDefaultReward();

View File

@ -24,9 +24,9 @@ import com.tommytony.war.volumes.Volume;
import com.tommytony.war.volumes.ZoneVolume;
/**
*
*
* @author tommytony
*
*
*/
public class WarzoneMapper {
@ -370,7 +370,7 @@ public class WarzoneMapper {
// spawnStyle
warzoneConfig.setString("spawnStyle", warzone.getSpawnStyle().toString());
// flagReturn
warzoneConfig.setString("flagReturn", warzone.getFlagReturn().toString());

View File

@ -34,7 +34,7 @@ import com.tommytony.war.volumes.ZoneVolume;
/**
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
*
*
* @author tommytony, Tim Düsterhus
* @package com.tommytony.war.mappers
*/
@ -42,7 +42,7 @@ public class ZoneVolumeMapper {
/**
* Loads the given volume
*
*
* @param ZoneVolume
* volume Volume to load
* @param String
@ -277,7 +277,7 @@ public class ZoneVolumeMapper {
/**
* Parses an inventory string
*
*
* @param String
* invString string to parse
* @return List<ItemStack> Parsed items
@ -309,7 +309,7 @@ public class ZoneVolumeMapper {
/**
* Saves the given volume
*
*
* @param Volume
* volume Volume to save
* @param String
@ -478,7 +478,7 @@ public class ZoneVolumeMapper {
/**
* Saves the Volume as a background-job
*
*
* @param ZoneVolme
* volume volume to save
* @param String
@ -494,7 +494,7 @@ public class ZoneVolumeMapper {
/**
* Deletes the given volume
*
*
* @param Volume
* volume volume to delete
* @param War
@ -510,7 +510,7 @@ public class ZoneVolumeMapper {
/**
* Deletes a volume file
*
*
* @param String
* path path of file
* @param War

View File

@ -6,15 +6,15 @@ import org.bukkit.command.CommandSender;
/**
* The purpose of this tool is twofold: 1: Avoid client crashes due to bad color formating. 2: Make color continue on word wrapping
*
*
* In minecraft the degree sign is used as a prefix to another char to create a color. For example the code for white is "\u00A7f". The "\u00A7" is the unicode notation for the degree sign and the "f" means white.
*
*
* When does minecraft wrap the text? After how many chars? Answer: Because the font isn't monospace this differs depending on what you write. However we can fit 53 "M" without wrapping and the 54th char would then wrap (be at the beginning of the next line instead) As there is no broader char than "M" we can know for sure the minimum line length is 53. Note that this means the number of DISPLAYED chars per row is 53. A degree sign and the char after will NOT count, as they will not be displayed as chars.
*
*
* Good to know: Numbers have the same font width as an M.
*
*
* When does the client crash? Answer: When a row ends with a degree char and optionally another sign after. Another way to say the same: When a line ends with either a broken or valid color notation. AND The client will ALWAYS crash if the sign after the last displayed char in a row is a degree char. A goofy way to explatin it: For a line with only "M" and numbers, the fiftyfourth "displayed char" musn't be a degree sign.
*
*
* WARNING: Above is a hypothesis I have created based on what my experiments have shown. I am fairly sure it is correct but please help me test it further.
*/
public class ChatFixUtil {
@ -23,13 +23,13 @@ public class ChatFixUtil {
/**
* This method wraps the msg for you at row lengths of 53, avoids client crash scenarios and makes the previous color continue on the next line.
*
*
* The upsides with filtering your messages through this method are: - No client crashes. - Line wrapping with preserved color.
*
*
* The downsides are: - The width of the chat window will not be used to it's fullest. For example you can fit more that 53 commas (,) in a chatwindow row but the line would break after 53 displayed chars.
*
*
* Suggested usage: NO NEED TO USE the fix method for static help pages in your plugin. As the text is static you can make sure there is no client crash yourself and be able to use the full line length.
*
*
* DO USE in cases like where you output colored messages with playernames in your plugin. As the player names have different length there is potential for client crash.
*/
public static ArrayList<String> fix(String msg) {

View File

@ -5,9 +5,9 @@ import org.bukkit.World;
import org.bukkit.block.Block;
/**
*
*
* @author tommytony
*
*
*/
public class BlockInfo {
private int x;

View File

@ -5,7 +5,7 @@ import org.bukkit.World;
import org.bukkit.block.Block;
/**
*
*
* @author tommytony
* @deprecated Broken, don't use.
*/

View File

@ -10,9 +10,9 @@ import org.bukkit.block.BlockFace;
import bukkit.tommytony.war.War;
/**
*
*
* @author tommytony
*
*
*/
@Deprecated
public class VerticalVolume extends Volume {

View File

@ -22,9 +22,9 @@ import bukkit.tommytony.war.War;
import com.tommytony.war.jobs.BlockResetJob;
/**
*
*
* @author tommytony
*
*
*/
public class Volume {
private final String name;

View File

@ -11,9 +11,9 @@ import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.ZoneVolumeMapper;
/**
*
*
* @author tommytony
*
*
*/
public class ZoneVolume extends Volume {