-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
145 additions
and
10 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
src/org/piotrwyrw/iridiumscoreboard/commands/ResetConfig.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,30 @@ | ||
package org.piotrwyrw.iridiumscoreboard.commands; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.piotrwyrw.iridiumscoreboard.IridiumScoreBoard; | ||
import org.piotrwyrw.iridiumscoreboard.config.IridiumScoreBoardConfiguration; | ||
import org.piotrwyrw.iridiumscoreboard.globals.Messages; | ||
import org.piotrwyrw.iridiumscoreboard.globals.Permissions; | ||
import org.piotrwyrw.iridiumscoreboard.scoreboard.ScoreUpdater; | ||
|
||
public class ResetConfig extends CommandHandler { | ||
|
||
@Override | ||
public boolean handleCommand(CommandSender sender, String[] args) { | ||
if (!sender.hasPermission(Permissions.RESET_CONFIG)) { | ||
sender.sendMessage(Messages.NO_PERMISSION); | ||
return false; | ||
} | ||
|
||
if (args.length != 1) { | ||
sender.sendMessage(Messages.EXPECTED_ARGUMENTS(0)); | ||
return false; | ||
} | ||
|
||
sender.sendMessage(Messages.RESETTING_CONF); | ||
IridiumScoreBoard.getInstance().saveResource("config.yml", true); | ||
sender.sendMessage(Messages.RESET_DONE); | ||
return true; | ||
} | ||
|
||
} |
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
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
50 changes: 50 additions & 0 deletions
50
src/org/piotrwyrw/iridiumscoreboard/listener/ClickableSign.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,50 @@ | ||
package org.piotrwyrw.iridiumscoreboard.listener; | ||
|
||
import java.util.List; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.block.Sign; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.Action; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.piotrwyrw.iridiumscoreboard.IridiumScoreBoard; | ||
import org.piotrwyrw.iridiumscoreboard.globals.Messages; | ||
import org.piotrwyrw.iridiumscoreboard.scoreboard.ScoreBoard; | ||
import org.piotrwyrw.iridiumscoreboard.util.LocationComparator; | ||
|
||
import com.iridium.iridiumskyblock.Island; | ||
import com.iridium.iridiumskyblock.Utils; | ||
|
||
public class ClickableSign implements Listener { | ||
|
||
@EventHandler | ||
public void signClicked(PlayerInteractEvent evt) { | ||
|
||
if (evt.getAction() != Action.RIGHT_CLICK_BLOCK || !(evt.getClickedBlock().getState() instanceof Sign)) { | ||
return; | ||
} | ||
|
||
ScoreBoard sb = IridiumScoreBoard.getScoreBoard(); | ||
List<Island> top = Utils.getTopIslands(); | ||
int iterations = ((top.size() <= sb.count()) ? top.size() : sb.count()); | ||
|
||
for (int a = 0; a < iterations; a ++) { | ||
Location loc = sb.scorepanels.get(a).location; | ||
if (LocationComparator.isSame(loc, evt.getClickedBlock().getLocation())) { | ||
for (int b = 0; b < Utils.getTopIslands().size(); b ++) { | ||
if (a == b) { | ||
if (!top.get(b).isVisit()) { | ||
evt.getPlayer().sendMessage(Messages.IS_PRIVATE); | ||
break; | ||
} | ||
evt.getPlayer().teleport(top.get(b).getHome()); | ||
evt.getPlayer().sendMessage(Messages.IS_SB_TP); | ||
} | ||
} | ||
} | ||
} | ||
return; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/org/piotrwyrw/iridiumscoreboard/util/LocationComparator.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,10 @@ | ||
package org.piotrwyrw.iridiumscoreboard.util; | ||
|
||
import org.bukkit.Location; | ||
|
||
public class LocationComparator { | ||
public static boolean isSame(Location loc1, Location loc2) { | ||
return ((loc1.getX() == loc2.getX()) && (loc1.getY() == loc2.getY()) && (loc1.getZ() == loc2.getZ())) | ||
? true : false; | ||
} | ||
} |
1f2303b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need a code cleanup pretty soon