-
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
1 parent
b87bd33
commit 357f959
Showing
3 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
6 changes: 5 additions & 1 deletion
6
src/main/java/com/mcstaralliance/informdearplayer/InformDearPlayer.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,21 +1,25 @@ | ||
package com.mcstaralliance.informdearplayer; | ||
|
||
import com.mcstaralliance.informdearplayer.listener.PlayerInteractListener; | ||
import com.mcstaralliance.informdearplayer.task.CheckRunnable; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class InformDearPlayer extends JavaPlugin { | ||
private static InformDearPlayer instance; | ||
|
||
@Override | ||
public void onEnable() { | ||
instance = this; | ||
saveDefaultConfig(); | ||
CheckRunnable checkRunnable = new CheckRunnable(); | ||
long interval = getConfig().getLong("resource-world-alert.interval"); | ||
checkRunnable.runTaskTimer(getInstance(), 5L, interval); | ||
Bukkit.getPluginManager().registerEvents(new PlayerInteractListener(), getInstance()); | ||
} | ||
|
||
|
||
public static InformDearPlayer getInstance(){ | ||
public static InformDearPlayer getInstance() { | ||
return instance; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/mcstaralliance/informdearplayer/listener/PlayerInteractListener.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,28 @@ | ||
package com.mcstaralliance.informdearplayer.listener; | ||
|
||
import com.mcstaralliance.informdearplayer.InformDearPlayer; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.Material; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
|
||
public class PlayerInteractListener implements Listener { | ||
FileConfiguration config = InformDearPlayer.getInstance().getConfig(); | ||
|
||
@EventHandler | ||
public void onPlayerInteract(PlayerInteractEvent event) { | ||
Player player = event.getPlayer(); | ||
if (event.getMaterial() == Material.WOOD_HOE) { | ||
String message = config.getString("resource-world-alert.message"); | ||
player.sendMessage(colorize(message)); | ||
} | ||
} | ||
|
||
|
||
public String colorize(String str) { | ||
return ChatColor.translateAlternateColorCodes('&', str); | ||
} | ||
} |
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