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

Update MoveListener.java #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
85 changes: 41 additions & 44 deletions src/com/bartekmajster/opensectors/MoveListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bartekmajster.opensectors;


import org.bukkit.plugin.*;
import org.bukkit.event.player.*;
import com.connorlinfoot.actionbarapi.*;
Expand All @@ -9,8 +8,7 @@
import org.bukkit.*;
import java.io.*;

public class MoveListener implements Listener
{
public class MoveListener implements Listener {
Sectors plugin;
Location center;

Expand All @@ -24,23 +22,23 @@ public MoveListener(final Sectors plugin) {
public void onMove(final PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();

if (from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ()) {
final Location ploc = event.getPlayer().getLocation();
final int distX = this.distX(ploc);
final int distZ = this.distZ(ploc);
final Player p = event.getPlayer();

if (distX > 500 || distZ > 500) {
String server = "";
if (distX >= distZ) {
final int xC = ploc.getBlockX() - this.plugin.config.center.getBlockX();
if (xC > 0) {
server = this.plugin.config.northServer;
}
else if (xC < 0) {
} else if (xC < 0) {
server = this.plugin.config.southServer;
}
}
else if (distZ > distX) {
} else if (distZ > distX) {
final int zC = ploc.getBlockZ() - this.plugin.config.center.getBlockZ();
if (zC > 0) {
server = this.plugin.config.eastServer;
Expand All @@ -50,15 +48,14 @@ else if (zC < 0) {
}
}
if (server.equalsIgnoreCase("border")) {
ActionBarAPI.sendActionBar(p, "9## cOsiagnales limit swiata! ##");
p.sendMessage("## cOsiagnales limit swiata! ##");
ActionBarAPI.sendActionBar(p, "§9## §cOsiagnales limit swiata! ##");
p.sendMessage("## §cOsiagnales limit swiata! ##");
ActionBarAPI.sendActionBar(p, "");
p.teleport(from);
return;
}
this.teleportServer(p, server);
}
else if (distX >= 469 || distZ >= 469) {
} else if (distX >= 469 || distZ >= 469) {
int distance = 0;
if (distX >= distZ) {
distance = 500 - distX;
Expand All @@ -67,131 +64,131 @@ else if (distZ > distX) {
distance = 500 - distZ;
}
if (distX == 469 || distZ == 469) {
ActionBarAPI.sendActionBar(p, "c");
ActionBarAPI.sendActionBar(p, "§c");
return;
}
if (distance >= 30) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:�8:::::::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:§8:::::::::::::::::::::::::::::§f}");
return;
}
if (distance >= 29) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::8::::::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::§8::::::::::::::::::::::::::::§f}");
return;
}
if (distance >= 28) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::8:::::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::§8:::::::::::::::::::::::::::§f}");
return;
}
if (distance >= 27) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::8::::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::§8::::::::::::::::::::::::::§f}");
return;
}
if (distance >= 26) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::8:::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::§8:::::::::::::::::::::::::§f}");
return;
}
if (distance >= 25) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::8::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::§8::::::::::::::::::::::::§f}");
return;
}
if (distance >= 24) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::8:::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::§8:::::::::::::::::::::::§f}");
return;
}
if (distance >= 23) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::8::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::§8::::::::::::::::::::::§f}");
return;
}
if (distance >= 22) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::8:::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::§8:::::::::::::::::::::§f}");
return;
}
if (distance >= 21) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::8::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::§8::::::::::::::::::::§f}");
return;
}
if (distance >= 20) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::8:::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::§8:::::::::::::::::::§f}");
return;
}
if (distance >= 19) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::8::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::§8::::::::::::::::::§f}");
return;
}
if (distance >= 18) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::8:::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::§8:::::::::::::::::§f}");
return;
}
if (distance >= 17) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::8::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::§8::::::::::::::::§f}");
return;
}
if (distance >= 16) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::8:::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::§8:::::::::::::::§f}");
return;
}
if (distance >= 15) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::8::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::§8::::::::::::::§f}");
return;
}
if (distance >= 14) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::8:::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::§8:::::::::::::§f}");
return;
}
if (distance >= 13) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::8::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::§8::::::::::::§f}");
return;
}
if (distance >= 12) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::::8:::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::::§8:::::::::::§f}");
return;
}
if (distance >= 11) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::::8::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::::§8::::::::::§f}");
return;
}
if (distance >= 10) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::::::8:::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::::::§8:::::::::§f}");
return;
}
if (distance >= 9) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::::::8::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::::::§8::::::::§f}");
return;
}
if (distance >= 8) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::::::::8:::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::::::::§8:::::::§f}");
return;
}
if (distance >= 7) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::::::::8::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::::::::§8::::::§f}");
return;
}
if (distance >= 6) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::::::::::8:::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::::::::::§8:::::§f}");
return;
}
if (distance >= 5) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::::::::::8::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::::::::::§8::::§f}");
return;
}
if (distance >= 4) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::::::::::::8:::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::::::::::::§8:::§f}");
return;
}
if (distance >= 3) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::::::::::::8::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::::::::::::§8::§f}");
return;
}
if (distance >= 2) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c:::::::::::::::::::::::::::::�8:�f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c:::::::::::::::::::::::::::::§8:§f}");
return;
}
if (distance > 1) {
ActionBarAPI.sendActionBar(p, "�c�lGranica sektora! �a�n" + distance + "�f �f{�c::::::::::::::::::::::::::::::f}");
ActionBarAPI.sendActionBar(p, "§c§lGranica sektora! §a§n" + distance + "§f §f{§c::::::::::::::::::::::::::::::§f}");
return;
}
if (distance > 0) {
ActionBarAPI.sendActionBar(p, "�c�lPrzekierowywanie na sektor: �9�l�nGLOBAL");
ActionBarAPI.sendActionBar(p, "§c§lPrzekierowywanie na sektor: §9§l§nGLOBAL");
}
}
}
Expand All @@ -204,8 +201,8 @@ public void teleportServer(final Player p, final String server) {
try {
out.writeUTF("Connect");
out.writeUTF(server);
} catch (IOException ex) {
}
catch (IOException ex) {}
p.sendPluginMessage((Plugin)this.plugin, "BungeeCord", b.toByteArray());
}

Expand Down