Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main extends JavaPlugin implements Listener{
- private static Cuboide Zone1;
- private static Cuboide Zone2;
- private Location loadLocation(String chemin){
- double x = getConfig().getDouble(chemin + ".x");
- double y = getConfig().getDouble(chemin + ".y");
- double z = getConfig().getDouble(chemin + ".z");
- World w = Bukkit.getWorld(getConfig().getString(chemin+".w"));
- return new Location(w,x,y,z);
- }
- private void saveLocation(String chemin, Location l){
- getConfig().set(chemin + ".x", l.getX());
- getConfig().set(chemin + ".y", l.getY());
- getConfig().set(chemin + ".z", l.getZ());
- getConfig().set(chemin + ".w", l.getWorld().getName());
- saveConfig();
- }
- private Boolean hasMoved(Location l1, Location l2){
- if(l1 != l2){
- return true;
- }else{
- return false;
- }
- }
- @EventHandler
- public void onMove(PlayerMoveEvent e){
- Player p = e.getPlayer();
- if(Zone1.isInCube(p)){
- p.sendMessage("§6Tu es dans la zone §4n°1§6 !");
- }else if(Zone2.isInCube(p)){
- p.sendMessage("§6Tu es dans la zone §4n°2§6 !");
- }
- }
- @Override
- public void onEnable() {
- saveConfig();
- getServer().getPluginManager().registerEvents(this, this);
- if(getConfig().getBoolean("location")){
- Zone1 = new Cuboide(loadLocation("zone1.l1"), loadLocation("zone1.l2"));
- Zone2 = new Cuboide(loadLocation("zone2.l1"), loadLocation("zone2.l2"));
- }
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player p = (Player) sender;
- if(cmd.getName().equalsIgnoreCase("setcube")){
- if(args.length == 2){
- if((args[1].equalsIgnoreCase("1") || args[1].equalsIgnoreCase("2"))){
- saveLocation(args[0]+".l"+args[1], p.getLocation());
- getConfig().set("location", true);
- saveConfig();
- p.sendMessage("§2La position §c"+args[1]+"§2 pour la zone §c"+args[0]+"§2 a été définis !");
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement