-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-organised the project, added sign break permission
- Loading branch information
Showing
9 changed files
with
110 additions
and
57 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 was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
.../creepysin/hubmanager/AllHubsCommand.java → ...pysin/hubmanager/cmds/AllHubsCommand.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package me.creepysin.hubmanager; | ||
package me.creepysin.hubmanager.cmds; | ||
|
||
import java.util.List; | ||
|
||
|
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
85 changes: 85 additions & 0 deletions
85
src/me/creepysin/hubmanager/listeners/HubSignListeners.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,85 @@ | ||
package me.creepysin.hubmanager.listeners; | ||
|
||
import org.bukkit.ChatColor; | ||
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.block.BlockBreakEvent; | ||
import org.bukkit.event.block.SignChangeEvent; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
|
||
import me.creepysin.hubmanager.HubTeleport; | ||
import me.creepysin.hubmanager.Main; | ||
|
||
public class HubSignListeners implements Listener { | ||
|
||
private Main plugin; | ||
private HubTeleport hubTele; | ||
|
||
public HubSignListeners(Main _main, HubTeleport _hubtele) { | ||
plugin = _main; | ||
hubTele = _hubtele; | ||
|
||
plugin.getLogger().info("Added events."); | ||
} | ||
|
||
@EventHandler | ||
public void onBlockBreak(BlockBreakEvent e) { | ||
// Check to see if it is a hub sign, and if it is then check to see if the player has the right permissions | ||
if(e.getBlock().getState() instanceof Sign) { | ||
Sign sign = (Sign) e.getBlock().getState(); | ||
|
||
if(sign.getLine(0).equalsIgnoreCase("[hub]")) { | ||
if(!e.getPlayer().hasPermission("hubmanager.signs.break")) { | ||
e.setCancelled(true); | ||
e.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to break hub signs!"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onSignChange(SignChangeEvent e) { | ||
if(e.getLine(0).equalsIgnoreCase("[hub]")) { | ||
|
||
// Check to see if the player has the right permissions | ||
if(!e.getPlayer().hasPermission("hubmanager.signs.create")) { | ||
e.setLine(0, "[§4Hub§0]"); | ||
e.setLine(1, ""); | ||
|
||
e.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to create hub signs!"); | ||
return; | ||
} | ||
|
||
e.setLine(0, "[Hub]"); | ||
|
||
e.setLine(1, plugin.getConfig().getString("signs.signHubColor") + e.getLine(1)); | ||
|
||
for (int i = 0; i < 2; i++ ) { | ||
e.setLine(i + 2, plugin.getConfig().getList("signs.messages").get(i).toString()); | ||
} | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerInteract(PlayerInteractEvent e) { | ||
if(!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return; | ||
|
||
if(e.getClickedBlock().getState() instanceof Sign) { | ||
Sign sign = (Sign) e.getClickedBlock().getState(); | ||
|
||
if(!e.getPlayer().hasPermission("hubmanager.signs.interact")) { | ||
if(!sign.getLine(0).equalsIgnoreCase("[hub]")) return; | ||
|
||
e.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to interact with hub signs!"); | ||
return; | ||
} | ||
|
||
if(sign.getLine(0).equalsIgnoreCase("[hub]")) { | ||
hubTele.TeleportPlayer(e.getPlayer(), sign.getLine(1).substring(2)); | ||
} | ||
} | ||
} | ||
|
||
} |