Add configurable messages.
This commit is contained in:
parent
db1912445e
commit
4537a5caa3
@ -49,3 +49,12 @@ sit-effects:
|
|||||||
healing:
|
healing:
|
||||||
amount: 1
|
amount: 1
|
||||||
max-percent: 100
|
max-percent: 100
|
||||||
|
messages:
|
||||||
|
sitting: '&7You are now sitting.'
|
||||||
|
standing: '&7You are no longer sitting.'
|
||||||
|
occupied: '&7This seat is occupied by &6%PLAYER%&7!'
|
||||||
|
reloaded: 'Chairs configuration reloaded.'
|
||||||
|
no-permission: '&cYou do not have permission to do this!'
|
||||||
|
enabled: '&7You have enabled chairs for yourself!'
|
||||||
|
disabled: '&7You have disabled chairs for yourself!'
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
package net.spoothie.chairs;
|
package net.spoothie.chairs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.server.v1_5_R1.DataWatcher;
|
import net.minecraft.server.v1_5_R2.DataWatcher;
|
||||||
import net.minecraft.server.v1_5_R1.WatchableObject;
|
import net.minecraft.server.v1_5_R2.WatchableObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,12 +6,12 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.minecraft.server.v1_5_R1.Packet40EntityMetadata;
|
import net.minecraft.server.v1_5_R2.Packet40EntityMetadata;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_5_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
@ -40,6 +40,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
static final Logger log = Logger.getLogger("Minecraft");
|
static final Logger log = Logger.getLogger("Minecraft");
|
||||||
public PluginManager pm;
|
public PluginManager pm;
|
||||||
public static ChairsIgnoreList ignoreList;
|
public static ChairsIgnoreList ignoreList;
|
||||||
|
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -114,6 +115,14 @@ public class Chairs extends JavaPlugin {
|
|||||||
sitMaxHealth = getConfig().getInt("sit-effects.healing.max-percent",100);
|
sitMaxHealth = getConfig().getInt("sit-effects.healing.max-percent",100);
|
||||||
sitHealthPerInterval = getConfig().getInt("sit-effects.healing.amount",1);
|
sitHealthPerInterval = getConfig().getInt("sit-effects.healing.amount",1);
|
||||||
|
|
||||||
|
msgSitting = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.sitting"));
|
||||||
|
msgStanding = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.standing"));
|
||||||
|
msgOccupied = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.occupied"));
|
||||||
|
msgNoPerm = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.no-permission"));
|
||||||
|
msgEnabled = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.enabled"));
|
||||||
|
msgDisabled = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.disabled"));
|
||||||
|
msgReloaded = ChatColor.translateAlternateColorCodes('&',getConfig().getString("messages.reloaded"));
|
||||||
|
|
||||||
for (String s : getConfig().getStringList("allowed-blocks")) {
|
for (String s : getConfig().getStringList("allowed-blocks")) {
|
||||||
String type;
|
String type;
|
||||||
double sh = sittingHeight;
|
double sh = sittingHeight;
|
||||||
@ -199,8 +208,8 @@ public class Chairs extends JavaPlugin {
|
|||||||
// Send stand packet to all online players
|
// Send stand packet to all online players
|
||||||
public void sendStand(Player p) {
|
public void sendStand(Player p) {
|
||||||
if (sit.containsKey(p.getName())) {
|
if (sit.containsKey(p.getName())) {
|
||||||
if (notifyplayer) {
|
if (notifyplayer && !msgStanding.isEmpty()) {
|
||||||
p.sendMessage(ChatColor.GRAY + "You are no longer sitting.");
|
p.sendMessage(msgStanding);
|
||||||
}
|
}
|
||||||
sit.remove(p.getName());
|
sit.remove(p.getName());
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.spoothie.chairs;
|
package net.spoothie.chairs;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -34,9 +33,13 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
plugin.loadConfig();
|
plugin.loadConfig();
|
||||||
plugin.restartEffectsTask();
|
plugin.restartEffectsTask();
|
||||||
sender.sendMessage("Chairs configuration file reloaded.");
|
if (!plugin.msgReloaded.isEmpty()) {
|
||||||
|
sender.sendMessage(plugin.msgReloaded);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GRAY + "No permission to do this!");
|
if (!plugin.msgNoPerm.isEmpty()) {
|
||||||
|
sender.sendMessage(plugin.msgNoPerm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
@ -44,17 +47,25 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("on")) {
|
if (args[0].equalsIgnoreCase("on")) {
|
||||||
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
||||||
ignoreList.removePlayer(p.getName());
|
ignoreList.removePlayer(p.getName());
|
||||||
p.sendMessage(ChatColor.GRAY + "You have enabled chairs for yourself!");
|
if (!plugin.msgEnabled.isEmpty()) {
|
||||||
|
p.sendMessage(plugin.msgEnabled);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(ChatColor.GRAY + "No permission to do this!");
|
if (!plugin.msgNoPerm.isEmpty()) {
|
||||||
|
p.sendMessage(plugin.msgNoPerm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("off")) {
|
if (args[0].equalsIgnoreCase("off")) {
|
||||||
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
||||||
ignoreList.addPlayer(p.getName());
|
ignoreList.addPlayer(p.getName());
|
||||||
p.sendMessage(ChatColor.GRAY + "You have disabled chairs for yourself!");
|
if (!plugin.msgDisabled.isEmpty()) {
|
||||||
|
p.sendMessage(plugin.msgDisabled);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(ChatColor.GRAY + "No permission to do this!");
|
if (!plugin.msgNoPerm.isEmpty()) {
|
||||||
|
p.sendMessage(plugin.msgNoPerm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -175,8 +174,8 @@ public class EventListener implements Listener {
|
|||||||
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
||||||
plugin.sit.remove(player.getName());
|
plugin.sit.remove(player.getName());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (plugin.notifyplayer) {
|
if (plugin.notifyplayer && !plugin.msgStanding.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.GRAY + "You are no longer sitting.");
|
player.sendMessage(plugin.msgStanding);
|
||||||
}
|
}
|
||||||
plugin.sendStand(player);
|
plugin.sendStand(player);
|
||||||
return;
|
return;
|
||||||
@ -237,7 +236,9 @@ public class EventListener implements Listener {
|
|||||||
if (!plugin.sit.isEmpty()) {
|
if (!plugin.sit.isEmpty()) {
|
||||||
for (String s : plugin.sit.keySet()) {
|
for (String s : plugin.sit.keySet()) {
|
||||||
if (plugin.sit.get(s).equals(block.getLocation())) {
|
if (plugin.sit.get(s).equals(block.getLocation())) {
|
||||||
player.sendMessage(ChatColor.GRAY + "This seat is occupied by " + s + "!");
|
if (!plugin.msgOccupied.isEmpty()) {
|
||||||
|
player.sendMessage(plugin.msgOccupied.replaceAll("%PLAYER%", s));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,8 +273,8 @@ public class EventListener implements Listener {
|
|||||||
player.teleport(plocation.add(0.5D, (sh - 0.5D), 0.5D));
|
player.teleport(plocation.add(0.5D, (sh - 0.5D), 0.5D));
|
||||||
}
|
}
|
||||||
player.setSneaking(true);
|
player.setSneaking(true);
|
||||||
if (plugin.notifyplayer) {
|
if (plugin.notifyplayer && !plugin.msgSitting.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.GRAY + "You are now sitting.");
|
player.sendMessage(plugin.msgSitting);
|
||||||
}
|
}
|
||||||
plugin.sit.put(player.getName(), block.getLocation());
|
plugin.sit.put(player.getName(), block.getLocation());
|
||||||
event.setUseInteractedBlock(Result.DENY);
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: Chairs
|
name: Chairs
|
||||||
version: 1.20.0
|
version: 1.21.0
|
||||||
description: Let players sit on blocks.
|
description: Let players sit on blocks.
|
||||||
authors:
|
authors:
|
||||||
- spoothie
|
- spoothie
|
||||||
|
Loading…
Reference in New Issue
Block a user