A feature-rich Minecraft plugin which enhances gaming experience
git clone git://soophie.de/poppy
1
main: poppy.Main2
name: poppy3
version: 0.0.13
version: 0.1.04
author: typable, chunksize5
api-version: 1.166
commands:
40
public void onEnable()41
{42
plugin = this;43
config = new Config("config/minecraft-hub.yml");43
config = new Config("config/poppy.yml");45
pluginManager = Bukkit.getPluginManager();
95
case "sethome":96
return setHome(player, args);97
case "setwarp":98
return addWarppoint(player, args);98
return setWarppoint(player, args);99
default:100
return false;101
}
226
}228
final String name = args[0];229
final Location location = config.getWarp(name);229
final Location location = config.getWarp(name.toLowerCase());231
if(location == null)232
{
257
return true;258
}260
private boolean addWarppoint(final Player player, final String[] args)260
private boolean setWarppoint(final Player player, final String[] args)261
{262
if(args.length != 1)263
{
275
try276
{277
if(!config.setWarp(name, player.getLocation()))277
if(!config.setWarp(name.toLowerCase(), player.getLocation()))278
{279
player.sendMessage(ChatColor.RED + "Warp point " + name + " already exists!");280
return true;
170
public static int calcTravelFee(final Location from, final Location to)171
{172
if(!isLocationInSameWorld(from, to))173
{174
return 0;175
}177
final Double distance = from.distance(to);178
int fee = (int) Math.floor(distance / (Constants.BLOCKS_PER_CHUNK * Constants.CHUNKS_PER_EMERALD));
193
public static boolean travelTo(final Plugin plugin, final Player player, final Location location)194
{195
if(!isLocationInSameWorld(player.getLocation(), location))196
{197
player.sendMessage(ChatColor.RED + "The warppoint cannot be located in this world!");198
return false;199
}201
final int fee = Utils.calcTravelFee(player.getLocation(), location);202
final String unit = fee == 1 ? "emerald" : "emeralds";
243
return true;244
}246
public static boolean isLocationInSameWorld(final Location from, final Location to)247
{248
return from.getWorld().getName().equals(to.getWorld().getName());249
}250
}