-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
189 additions
and
6 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/us/talabrek/ultimateskyblock/LocationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package us.talabrek.ultimateskyblock; | ||
|
||
import org.bukkit.Location; | ||
|
||
/** | ||
* Responsible for various transformations of locations. | ||
*/ | ||
public enum LocationUtil {; | ||
public static String asString(Location loc) { | ||
if (loc == null) { | ||
return null; | ||
} | ||
String s = ""; | ||
if (loc.getWorld() != null && loc.getWorld().getName() != null) { | ||
s += loc.getWorld().getName() + ":"; | ||
} | ||
s += String.format("%5.2f,%5.2f,%5.2f", loc.getX(), loc.getY(), loc.getZ()); | ||
if (loc.getYaw() != 0f || loc.getPitch() != 0f) { | ||
s += String.format(":%3.2f:%3.2f", loc.getYaw(), loc.getPitch()); | ||
} | ||
return s; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package us.talabrek.ultimateskyblock; | ||
|
||
public enum TimeUtil {; | ||
private static final long SEC = 1000; | ||
private static final long MIN = 60*SEC; | ||
private static final long HOUR = 60*MIN; | ||
private static final long DAYS = 24*HOUR; | ||
|
||
public static String millisAsString(long millis) { | ||
long d = millis / DAYS; | ||
long h = (millis % DAYS) / HOUR; | ||
long m = (millis % HOUR) / MIN; | ||
long s = (millis % MIN) / SEC; | ||
String str = ""; | ||
if (d > 0) { | ||
str += d + "d"; | ||
} | ||
if (h > 0) { | ||
str += " " + h + "h"; | ||
} | ||
if (m > 0) { | ||
str += " " + m + "m"; | ||
} | ||
if (s > 0) { | ||
str += " " + s + "s"; | ||
} | ||
return str.trim(); | ||
} | ||
|
||
public static String ticksAsString(int ticks) { | ||
return millisAsString(ticks * 50); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/us/talabrek/ultimateskyblock/command/admin/FixCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package us.talabrek.ultimateskyblock.command.admin; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import us.talabrek.ultimateskyblock.command.common.AbstractUSBCommand; | ||
import us.talabrek.ultimateskyblock.handler.WorldGuardHandler; | ||
import us.talabrek.ultimateskyblock.player.PlayerInfo; | ||
import us.talabrek.ultimateskyblock.uSkyBlock; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Tries to clear an area of flatland. | ||
*/ | ||
public class FixCommand extends AbstractUSBCommand { | ||
private final uSkyBlock plugin; | ||
|
||
public FixCommand(uSkyBlock plugin) { | ||
super("fix-flatland", "usb.admin.remove", "?player", "tries to fix the the area of flatland."); | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender sender, String alias, Map<String, Object> data, String... args) { | ||
String playerName = null; | ||
if (args.length == 1) { | ||
playerName = args[0]; | ||
} else if (args.length == 0 && sender instanceof Player) { | ||
playerName = WorldGuardHandler.getRegionAt(((Player) sender).getLocation()); | ||
} | ||
PlayerInfo playerInfo = playerName != null ? plugin.getPlayerInfo(playerName) : null; | ||
if (!tryFlatlandFix(sender, playerName, playerInfo)) { | ||
sender.sendMessage("\u00a74No valid island found"); | ||
} | ||
return true; | ||
} | ||
|
||
private boolean tryFlatlandFix(CommandSender sender, String playerName, PlayerInfo playerInfo) { | ||
if (playerInfo.getHasIsland() && playerInfo.getIslandLocation() != null) { | ||
// TODO: 29/12/2014 - R4zorax: Load chunks first? | ||
if (!plugin.getIslandLogic().clearFlatland(sender, playerInfo.getIslandLocation(), 0)) { | ||
sender.sendMessage("\u00a74No flatland detected at " + playerName + "'s island!"); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters