mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
@@ -205,9 +205,8 @@ public class ResidenceMain extends JavaPlugin {
|
|||||||
final ClaimedResidence res = rmanager.getByLoc(loc);
|
final ClaimedResidence res = rmanager.getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
return res.getPermissions();
|
return res.getPermissions();
|
||||||
} else {
|
|
||||||
return wmanager.getPerms(loc.getWorld().getName());
|
|
||||||
}
|
}
|
||||||
|
return wmanager.getPerms(loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
public FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
||||||
@@ -692,13 +691,12 @@ public class ResidenceMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
if (cmanager.getResidenceNameRegex() == null) {
|
if (cmanager.getResidenceNameRegex() == null) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
final String namecheck = name.replaceAll(cmanager.getResidenceNameRegex(), "");
|
|
||||||
if (!name.equals(namecheck)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
final String namecheck = name.replaceAll(cmanager.getResidenceNameRegex(), "");
|
||||||
|
if (!name.equals(namecheck)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkNewLanguageVersion(final String lang) throws IOException, FileNotFoundException, InvalidConfigurationException {
|
private boolean checkNewLanguageVersion(final String lang) throws IOException, FileNotFoundException, InvalidConfigurationException {
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public class CommandLease extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||||
final ClaimedResidence res = rmanager.getByName(area);
|
final ClaimedResidence res = rmanager.getByName(area);
|
||||||
@@ -64,7 +63,6 @@ public class CommandLease extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
@@ -80,7 +78,6 @@ public class CommandLease extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
int days;
|
int days;
|
||||||
try {
|
try {
|
||||||
@@ -90,7 +87,6 @@ public class CommandLease extends BaseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
leasemanager.setExpireTime(player, args[1], days);
|
leasemanager.setExpireTime(player, args[1], days);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class CommandRemove extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(player, area, resadmin);
|
rmanager.removeResidence(player, area, resadmin);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED));
|
||||||
@@ -53,8 +52,8 @@ public class CommandRemove extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(player, area, resadmin);
|
rmanager.removeResidence(player, area, resadmin);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
|
|||||||
@@ -59,10 +59,8 @@ public class CommandSubZone extends BaseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
|
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,94 +16,90 @@ import com.earth2me.essentials.api.UserDoesNotExistException;
|
|||||||
*/
|
*/
|
||||||
public class EssentialsEcoAdapter implements EconomyInterface {
|
public class EssentialsEcoAdapter implements EconomyInterface {
|
||||||
|
|
||||||
Essentials plugin;
|
Essentials plugin;
|
||||||
|
|
||||||
public EssentialsEcoAdapter(Essentials p) {
|
public EssentialsEcoAdapter(final Essentials p) {
|
||||||
plugin = p;
|
plugin = p;
|
||||||
String serverland = "Server Land";
|
final String serverland = "Server Land";
|
||||||
if (!Economy.playerExists(serverland)) {
|
if (!Economy.playerExists(serverland)) {
|
||||||
Economy.createNPC(serverland);
|
Economy.createNPC(serverland);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBalance(String playerName) {
|
public boolean add(final String playerName, final double amount) {
|
||||||
try {
|
if (Economy.playerExists(playerName)) {
|
||||||
if (Economy.playerExists(playerName)) {
|
try {
|
||||||
return Economy.getMoney(playerName);
|
Economy.add(playerName, amount);
|
||||||
} else {
|
return true;
|
||||||
return 0;
|
} catch (final UserDoesNotExistException ex) {
|
||||||
}
|
return false;
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (final NoLoanPermittedException ex) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAfford(String playerName, double amount) {
|
public boolean canAfford(final String playerName, final double amount) {
|
||||||
try {
|
try {
|
||||||
if (Economy.playerExists(playerName)) {
|
if (Economy.playerExists(playerName)) {
|
||||||
return Economy.hasEnough(playerName, amount);
|
return Economy.hasEnough(playerName, amount);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(String playerName, double amount) {
|
public double getBalance(final String playerName) {
|
||||||
if (Economy.playerExists(playerName)) {
|
try {
|
||||||
try {
|
if (Economy.playerExists(playerName)) {
|
||||||
Economy.add(playerName, amount);
|
return Economy.getMoney(playerName);
|
||||||
return true;
|
}
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
return false;
|
}
|
||||||
} catch (NoLoanPermittedException ex) {
|
return 0;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean subtract(String playerName, double amount) {
|
public String getName() {
|
||||||
if (Economy.playerExists(playerName)) {
|
return "EssentialsEconomy";
|
||||||
try {
|
}
|
||||||
Economy.subtract(playerName, amount);
|
|
||||||
return true;
|
|
||||||
} catch (UserDoesNotExistException ex) {
|
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean transfer(String playerFrom, String playerTo, double amount) {
|
public boolean subtract(final String playerName, final double amount) {
|
||||||
try {
|
if (Economy.playerExists(playerName)) {
|
||||||
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
|
try {
|
||||||
if (!subtract(playerFrom, amount))
|
Economy.subtract(playerName, amount);
|
||||||
return false;
|
return true;
|
||||||
if (!add(playerTo, amount)) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
add(playerFrom, amount);
|
return false;
|
||||||
return false;
|
} catch (final NoLoanPermittedException ex) {
|
||||||
}
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
} catch (UserDoesNotExistException ex) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||||
return "EssentialsEconomy";
|
try {
|
||||||
}
|
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
|
||||||
|
if (!subtract(playerFrom, amount))
|
||||||
|
return false;
|
||||||
|
if (!add(playerTo, amount)) {
|
||||||
|
add(playerFrom, amount);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (final UserDoesNotExistException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.citycraft.Residence.itemlist;
|
package cn.citycraft.Residence.itemlist;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -21,198 +21,166 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class ItemList {
|
public class ItemList {
|
||||||
|
|
||||||
protected List<Material> list;
|
public static enum ListType {
|
||||||
protected ListType type;
|
BLACKLIST,
|
||||||
|
WHITELIST,
|
||||||
|
IGNORELIST,
|
||||||
|
OTHER
|
||||||
|
}
|
||||||
|
|
||||||
public ItemList(ListType listType)
|
protected List<Material> list;
|
||||||
{
|
|
||||||
this();
|
|
||||||
type = listType;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ItemList()
|
protected ListType type;
|
||||||
{
|
|
||||||
list = new ArrayList<Material>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum ListType
|
public ItemList(final ListType listType) {
|
||||||
{
|
this();
|
||||||
BLACKLIST,WHITELIST,IGNORELIST,OTHER
|
type = listType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListType getType()
|
protected ItemList() {
|
||||||
{
|
list = new ArrayList<Material>();
|
||||||
return type;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(Material mat)
|
public static ItemList load(final Map<String, Object> map) {
|
||||||
{
|
final ItemList newlist = new ItemList();
|
||||||
return list.contains(mat);
|
return load(map, newlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Material mat)
|
public static ItemList readList(final ConfigurationSection node) {
|
||||||
{
|
return ItemList.readList(node, new ItemList());
|
||||||
if(!list.contains(mat))
|
}
|
||||||
list.add(mat);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean toggle(Material mat)
|
@SuppressWarnings("unchecked")
|
||||||
{
|
protected static ItemList load(final Map<String, Object> map, final ItemList newlist) {
|
||||||
if(list.contains(mat))
|
try {
|
||||||
{
|
newlist.type = ListType.valueOf((String) map.get("Type"));
|
||||||
list.remove(mat);
|
final List<String> list = (List<String>) map.get("ItemList");
|
||||||
return false;
|
for (final String item : list) {
|
||||||
}
|
newlist.add(Material.valueOf(item));
|
||||||
else
|
}
|
||||||
{
|
} catch (final Exception ex) {
|
||||||
list.add(mat);
|
}
|
||||||
return true;
|
return newlist;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Material mat)
|
@SuppressWarnings("deprecation")
|
||||||
{
|
protected static ItemList readList(final ConfigurationSection node, final ItemList list) {
|
||||||
list.remove(mat);
|
final ListType type = ListType.valueOf(node.getString("Type", "").toUpperCase());
|
||||||
}
|
list.type = type;
|
||||||
|
final List<String> items = node.getStringList("Items");
|
||||||
|
if (items != null) {
|
||||||
|
for (final String item : items) {
|
||||||
|
int parse = -1;
|
||||||
|
try {
|
||||||
|
parse = Integer.parseInt(item);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
}
|
||||||
|
if (parse == -1) {
|
||||||
|
try {
|
||||||
|
list.add(Material.valueOf(item.toUpperCase()));
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
list.add(Material.getMaterial(parse));
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAllowed(Material mat)
|
public void add(final Material mat) {
|
||||||
{
|
if (!list.contains(mat))
|
||||||
if(type == ListType.BLACKLIST)
|
list.add(mat);
|
||||||
{
|
}
|
||||||
if(list.contains(mat))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(type == ListType.WHITELIST)
|
|
||||||
{
|
|
||||||
if(list.contains(mat))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIgnored(Material mat)
|
public boolean contains(final Material mat) {
|
||||||
{
|
return list.contains(mat);
|
||||||
if(type == ListType.IGNORELIST)
|
}
|
||||||
{
|
|
||||||
if(list.contains(mat))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isListed(Material mat)
|
public int getListSize() {
|
||||||
{
|
return list.size();
|
||||||
return this.contains(mat);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getListSize()
|
public ListType getType() {
|
||||||
{
|
return type;
|
||||||
return list.size();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemList readList(ConfigurationSection node)
|
public boolean isAllowed(final Material mat) {
|
||||||
{
|
if (type == ListType.BLACKLIST) {
|
||||||
return ItemList.readList(node, new ItemList());
|
if (list.contains(mat)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (type == ListType.WHITELIST) {
|
||||||
|
if (list.contains(mat)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
public boolean isIgnored(final Material mat) {
|
||||||
protected static ItemList readList(ConfigurationSection node, ItemList list)
|
if (type == ListType.IGNORELIST) {
|
||||||
{
|
if (list.contains(mat)) {
|
||||||
ListType type = ListType.valueOf(node.getString("Type","").toUpperCase());
|
return true;
|
||||||
list.type = type;
|
}
|
||||||
List<String> items = node.getStringList("Items");
|
}
|
||||||
if (items != null) {
|
return false;
|
||||||
for (String item : items) {
|
}
|
||||||
int parse = -1;
|
|
||||||
try {
|
|
||||||
parse = Integer.parseInt(item);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
if (parse == -1) {
|
|
||||||
try {
|
|
||||||
list.add(Material.valueOf(item.toUpperCase()));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
list.add(Material.getMaterial(parse));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printList(Player player)
|
public boolean isListed(final Material mat) {
|
||||||
{
|
return this.contains(mat);
|
||||||
StringBuilder builder = new StringBuilder();
|
}
|
||||||
boolean first = true;
|
|
||||||
for(Material mat : list)
|
|
||||||
{
|
|
||||||
if(!first)
|
|
||||||
builder.append(", ");
|
|
||||||
else
|
|
||||||
builder.append(ChatColor.YELLOW);
|
|
||||||
builder.append(mat);
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
player.sendMessage(builder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material[] toArray()
|
public void printList(final Player player) {
|
||||||
{
|
final StringBuilder builder = new StringBuilder();
|
||||||
Material mats[] = new Material[list.size()];
|
boolean first = true;
|
||||||
int i = 0;
|
for (final Material mat : list) {
|
||||||
for(Material mat : list)
|
if (!first)
|
||||||
{
|
builder.append(", ");
|
||||||
mats[i] = mat;
|
else
|
||||||
i++;
|
builder.append(ChatColor.YELLOW);
|
||||||
}
|
builder.append(mat);
|
||||||
return mats;
|
first = false;
|
||||||
}
|
}
|
||||||
|
player.sendMessage(builder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String,Object> save()
|
public void remove(final Material mat) {
|
||||||
{
|
list.remove(mat);
|
||||||
Map<String, Object> saveMap = new LinkedHashMap<String,Object>();
|
}
|
||||||
saveMap.put("Type", type.toString());
|
|
||||||
List<String> saveList = new ArrayList<String>();
|
|
||||||
for(Material mat : list)
|
|
||||||
{
|
|
||||||
saveList.add(mat.toString());
|
|
||||||
}
|
|
||||||
saveMap.put("ItemList", saveList);
|
|
||||||
return saveMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemList load(Map<String,Object> map)
|
public Map<String, Object> save() {
|
||||||
{
|
final Map<String, Object> saveMap = new LinkedHashMap<String, Object>();
|
||||||
ItemList newlist = new ItemList();
|
saveMap.put("Type", type.toString());
|
||||||
return load(map,newlist);
|
final List<String> saveList = new ArrayList<String>();
|
||||||
}
|
for (final Material mat : list) {
|
||||||
|
saveList.add(mat.toString());
|
||||||
|
}
|
||||||
|
saveMap.put("ItemList", saveList);
|
||||||
|
return saveMap;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public Material[] toArray() {
|
||||||
protected static ItemList load(Map<String,Object> map, ItemList newlist)
|
final Material mats[] = new Material[list.size()];
|
||||||
{
|
int i = 0;
|
||||||
try
|
for (final Material mat : list) {
|
||||||
{
|
mats[i] = mat;
|
||||||
newlist.type = ListType.valueOf((String) map.get("Type"));
|
i++;
|
||||||
List<String> list = (List<String>) map.get("ItemList");
|
}
|
||||||
for(String item : list)
|
return mats;
|
||||||
{
|
}
|
||||||
newlist.add(Material.valueOf(item));
|
|
||||||
}
|
public boolean toggle(final Material mat) {
|
||||||
}
|
if (list.contains(mat)) {
|
||||||
catch (Exception ex)
|
list.remove(mat);
|
||||||
{}
|
return false;
|
||||||
return newlist;
|
}
|
||||||
}
|
list.add(mat);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,497 +52,494 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class ResidencePlayerListener implements Listener {
|
public class ResidencePlayerListener implements Listener {
|
||||||
|
|
||||||
protected boolean chatenabled;
|
protected boolean chatenabled;
|
||||||
protected Map<String, String> currentRes;
|
protected Map<String, String> currentRes;
|
||||||
protected Map<String, Location> lastOutsideLoc;
|
protected Map<String, Location> lastOutsideLoc;
|
||||||
protected Map<String, Long> lastUpdate;
|
protected Map<String, Long> lastUpdate;
|
||||||
protected int minUpdateTime;
|
protected int minUpdateTime;
|
||||||
protected List<String> playerToggleChat;
|
protected List<String> playerToggleChat;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public ResidencePlayerListener(final ResidenceMain plugin) {
|
public ResidencePlayerListener(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
currentRes = new HashMap<>();
|
currentRes = new HashMap<>();
|
||||||
lastUpdate = new HashMap<>();
|
lastUpdate = new HashMap<>();
|
||||||
lastOutsideLoc = new HashMap<>();
|
lastOutsideLoc = new HashMap<>();
|
||||||
playerToggleChat = new ArrayList<>();
|
playerToggleChat = new ArrayList<>();
|
||||||
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
|
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
|
||||||
chatenabled = plugin.getConfigManager().chatEnabled();
|
chatenabled = plugin.getConfigManager().chatEnabled();
|
||||||
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
lastUpdate.put(player.getName(), System.currentTimeMillis());
|
lastUpdate.put(player.getName(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrentResidenceName(final String player) {
|
public String getCurrentResidenceName(final String player) {
|
||||||
return currentRes.get(player);
|
return currentRes.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
|
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
|
|
||||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
String areaname = null;
|
String areaname = null;
|
||||||
boolean chatchange = false;
|
boolean chatchange = false;
|
||||||
String subzone = null;
|
String subzone = null;
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
areaname = plugin.getResidenceManager().getNameByLoc(loc);
|
areaname = plugin.getResidenceManager().getNameByLoc(loc);
|
||||||
while (res.getSubzoneByLoc(player.getLocation()) != null) {
|
while (res.getSubzoneByLoc(player.getLocation()) != null) {
|
||||||
subzone = res.getSubzoneNameByLoc(player.getLocation());
|
subzone = res.getSubzoneNameByLoc(player.getLocation());
|
||||||
res = res.getSubzoneByLoc(player.getLocation());
|
res = res.getSubzoneByLoc(player.getLocation());
|
||||||
areaname = areaname + "." + subzone;
|
areaname = areaname + "." + subzone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClaimedResidence ResOld = null;
|
ClaimedResidence ResOld = null;
|
||||||
if (currentRes.containsKey(pname)) {
|
if (currentRes.containsKey(pname)) {
|
||||||
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
|
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
|
||||||
if (ResOld == null) {
|
if (ResOld == null) {
|
||||||
currentRes.remove(pname);
|
currentRes.remove(pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
lastOutsideLoc.put(pname, loc);
|
lastOutsideLoc.put(pname, loc);
|
||||||
if (ResOld != null) {
|
if (ResOld != null) {
|
||||||
final String leave = ResOld.getLeaveMessage();
|
final String leave = ResOld.getLeaveMessage();
|
||||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
|
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
|
||||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||||
|
|
||||||
if (leave != null && !leave.equals("")) {
|
if (leave != null && !leave.equals("")) {
|
||||||
if (plugin.getConfigManager().useActionBar()) {
|
if (plugin.getConfigManager().useActionBar()) {
|
||||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentRes.remove(pname);
|
currentRes.remove(pname);
|
||||||
plugin.getChatManager().removeFromChannel(pname);
|
plugin.getChatManager().removeFromChannel(pname);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
|
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
|
||||||
final Location lastLoc = lastOutsideLoc.get(pname);
|
final Location lastLoc = lastOutsideLoc.get(pname);
|
||||||
if (lastLoc != null) {
|
if (lastLoc != null) {
|
||||||
player.teleport(lastLoc);
|
player.teleport(lastLoc);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(res.getOutsideFreeLoc(loc));
|
player.teleport(res.getOutsideFreeLoc(loc));
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastOutsideLoc.put(pname, loc);
|
lastOutsideLoc.put(pname, loc);
|
||||||
if (!currentRes.containsKey(pname) || ResOld != res) {
|
if (!currentRes.containsKey(pname) || ResOld != res) {
|
||||||
currentRes.put(pname, areaname);
|
currentRes.put(pname, areaname);
|
||||||
if (subzone == null) {
|
if (subzone == null) {
|
||||||
chatchange = true;
|
chatchange = true;
|
||||||
}
|
}
|
||||||
ClaimedResidence chgFrom = null;
|
ClaimedResidence chgFrom = null;
|
||||||
if (ResOld != res && ResOld != null) {
|
if (ResOld != res && ResOld != null) {
|
||||||
final String leave = ResOld.getLeaveMessage();
|
final String leave = ResOld.getLeaveMessage();
|
||||||
chgFrom = ResOld;
|
chgFrom = ResOld;
|
||||||
|
|
||||||
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
|
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
|
||||||
if (plugin.getConfigManager().useActionBar()) {
|
if (plugin.getConfigManager().useActionBar()) {
|
||||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String enterMessage = res.getEnterMessage();
|
final String enterMessage = res.getEnterMessage();
|
||||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
|
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
|
||||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||||
|
|
||||||
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
|
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
|
||||||
if (plugin.getConfigManager().useActionBar()) {
|
if (plugin.getConfigManager().useActionBar()) {
|
||||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chatchange && chatenabled) {
|
if (chatchange && chatenabled) {
|
||||||
plugin.getChatManager().setChannel(pname, areaname);
|
plugin.getChatManager().setChannel(pname, areaname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
|
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
|
||||||
try {
|
try {
|
||||||
message = message.replaceAll("%player", player.getName());
|
message = message.replaceAll("%player", player.getName());
|
||||||
message = message.replaceAll("%owner", res.getPermissions().getOwner());
|
message = message.replaceAll("%owner", res.getPermissions().getOwner());
|
||||||
message = message.replaceAll("%residence", areaname);
|
message = message.replaceAll("%residence", areaname);
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
|
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (plugin.getRentManager().isRented(res.getName())) {
|
if (plugin.getRentManager().isRented(res.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
||||||
if (!perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true))) {
|
if (!perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true))) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
|
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (plugin.getRentManager().isRented(res.getName())) {
|
if (plugin.getRentManager().isRented(res.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
||||||
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||||
if (!hasbucket) {
|
if (!hasbucket) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
||||||
final String pname = event.getPlayer().getName();
|
final String pname = event.getPlayer().getName();
|
||||||
if (chatenabled && playerToggleChat.contains(pname)) {
|
if (chatenabled && playerToggleChat.contains(pname)) {
|
||||||
final String area = currentRes.get(pname);
|
final String area = currentRes.get(pname);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
channel.chat(pname, event.getMessage());
|
channel.chat(pname, event.getMessage());
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Material heldItem = player.getItemInHand().getType();
|
final Material heldItem = player.getItemInHand().getType();
|
||||||
final Block block = event.getClickedBlock();
|
final Block block = event.getClickedBlock();
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Material mat = block.getType();
|
final Material mat = block.getType();
|
||||||
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|
||||||
|| event.getAction() == Action.PHYSICAL)) {
|
|| event.getAction() == Action.PHYSICAL)) {
|
||||||
final int typeId = player.getItemInHand().getTypeId();
|
final int typeId = player.getItemInHand().getTypeId();
|
||||||
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
|
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
|
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||||
final boolean resadmin = plugin.isResAdminOn(player);
|
final boolean resadmin = plugin.isResAdminOn(player);
|
||||||
if (event.getAction() == Action.PHYSICAL) {
|
if (event.getAction() == Action.PHYSICAL) {
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||||
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
|
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
|
||||||
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
|
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
|
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wep != null) {
|
if (wep != null) {
|
||||||
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|
||||||
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
|
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
final Location loc = block.getLocation();
|
final Location loc = block.getLocation();
|
||||||
plugin.getSelectionManager().placeLoc1(player, loc);
|
plugin.getSelectionManager().placeLoc1(player, loc);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
final Location loc = block.getLocation();
|
final Location loc = block.getLocation();
|
||||||
plugin.getSelectionManager().placeLoc2(player, loc);
|
plugin.getSelectionManager().placeLoc2(player, loc);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
|
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
final Location loc = block.getLocation();
|
final Location loc = block.getLocation();
|
||||||
final String res = plugin.getResidenceManager().getNameByLoc(loc);
|
final String res = plugin.getResidenceManager().getNameByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
plugin.getResidenceManager().printAreaInfo(res, player);
|
plugin.getResidenceManager().printAreaInfo(res, player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
|
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (heldItem != null) {
|
if (heldItem != null) {
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
if (player.getItemInHand().getTypeId() == 351) {
|
if (player.getItemInHand().getTypeId() == 351) {
|
||||||
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
|
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
|
||||||
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
|
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
|
||||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin.isGt1_8()) {
|
if (plugin.isGt1_8()) {
|
||||||
if (heldItem == Material.ARMOR_STAND) {
|
if (heldItem == Material.ARMOR_STAND) {
|
||||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
|
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
|
||||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||||
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
|
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
|
||||||
if (mat == checkMat.getKey()) {
|
if (mat == checkMat.getKey()) {
|
||||||
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
|
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
|
||||||
if (hasuse || checkMat.getValue().equals("container")) {
|
if (hasuse || checkMat.getValue().equals("container")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
|
||||||
return;
|
} else {
|
||||||
} else {
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
}
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
|
||||||
}
|
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
|
||||||
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
|
event.setCancelled(true);
|
||||||
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||||
event.setCancelled(true);
|
return;
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
}
|
||||||
return;
|
}
|
||||||
}
|
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
|
||||||
}
|
if (!hasuse) {
|
||||||
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
|
event.setCancelled(true);
|
||||||
if (!hasuse) {
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||||
event.setCancelled(true);
|
return;
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
}
|
||||||
return;
|
}
|
||||||
}
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
}
|
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (!hasuse) {
|
||||||
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
|
event.setCancelled(true);
|
||||||
if (!hasuse) {
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||||
event.setCancelled(true);
|
}
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Entity ent = event.getRightClicked();
|
final Entity ent = event.getRightClicked();
|
||||||
/* Trade */
|
/* Trade */
|
||||||
if (ent.getType() == EntityType.VILLAGER) {
|
if (ent.getType() == EntityType.VILLAGER) {
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
|
||||||
|
|
||||||
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
|
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Container - ItemFrame protection */
|
/* Container - ItemFrame protection */
|
||||||
final Material heldItem = player.getItemInHand().getType();
|
final Material heldItem = player.getItemInHand().getType();
|
||||||
if (!(ent instanceof Hanging)) {
|
if (!(ent instanceof Hanging)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Hanging hanging = (Hanging) ent;
|
final Hanging hanging = (Hanging) ent;
|
||||||
if (hanging.getType() != EntityType.ITEM_FRAME) {
|
if (hanging.getType() != EntityType.ITEM_FRAME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||||
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
lastUpdate.put(player.getName(), 0L);
|
lastUpdate.put(player.getName(), 0L);
|
||||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||||
plugin.turnResAdminOn(player);
|
plugin.turnResAdminOn(player);
|
||||||
}
|
}
|
||||||
handleNewLocation(player, player.getLocation(), false);
|
handleNewLocation(player, player.getLocation(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerMove(final PlayerMoveEvent event) {
|
public void onPlayerMove(final PlayerMoveEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
if (!lastUpdate.containsKey(player.getName())) {
|
if (!lastUpdate.containsKey(player.getName())) {
|
||||||
lastUpdate.put(player.getName(), now);
|
lastUpdate.put(player.getName(), now);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long last = lastUpdate.get(player.getName());
|
final long last = lastUpdate.get(player.getName());
|
||||||
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
|
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastUpdate.put(player.getName(), now);
|
lastUpdate.put(player.getName(), now);
|
||||||
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
|
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
|
||||||
if (event.getFrom().distance(event.getTo()) == 0) {
|
if (event.getFrom().distance(event.getTo()) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleNewLocation(player, event.getTo(), true);
|
handleNewLocation(player, event.getTo(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||||
final String pname = event.getPlayer().getName();
|
final String pname = event.getPlayer().getName();
|
||||||
currentRes.remove(pname);
|
currentRes.remove(pname);
|
||||||
lastUpdate.remove(pname);
|
lastUpdate.remove(pname);
|
||||||
lastOutsideLoc.remove(pname);
|
lastOutsideLoc.remove(pname);
|
||||||
plugin.getChatManager().removeFromChannel(pname);
|
plugin.getChatManager().removeFromChannel(pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerSpawn(final PlayerRespawnEvent event) {
|
public void onPlayerSpawn(final PlayerRespawnEvent event) {
|
||||||
Location loc = event.getRespawnLocation();
|
Location loc = event.getRespawnLocation();
|
||||||
final Boolean bed = event.isBedSpawn();
|
final Boolean bed = event.isBedSpawn();
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
|
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bed) {
|
if (bed) {
|
||||||
loc = player.getWorld().getSpawnLocation();
|
loc = player.getWorld().getSpawnLocation();
|
||||||
}
|
}
|
||||||
res = plugin.getResidenceManager().getByLoc(loc);
|
res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
|
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||||
loc = res.getOutsideFreeLoc(loc);
|
loc = res.getOutsideFreeLoc(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
|
||||||
event.setRespawnLocation(loc);
|
event.setRespawnLocation(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||||
final Location loc = event.getTo();
|
final Location loc = event.getTo();
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
|
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
|
||||||
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
|
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
|
||||||
handleNewLocation(player, loc, false);
|
handleNewLocation(player, loc, false);
|
||||||
} else {
|
} else {
|
||||||
final String areaname = res.getName();
|
final String areaname = res.getName();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tooglePlayerResidenceChat(final Player player) {
|
public void tooglePlayerResidenceChat(final Player player) {
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (playerToggleChat.contains(pname)) {
|
if (playerToggleChat.contains(pname)) {
|
||||||
playerToggleChat.remove(pname);
|
playerToggleChat.remove(pname);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
|
||||||
} else {
|
} else {
|
||||||
playerToggleChat.add(pname);
|
playerToggleChat.add(pname);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCanUseEntity(final Material mat, final Block block) {
|
private boolean isCanUseEntity(final Material mat, final Block block) {
|
||||||
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
|
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCanUseEntity_BothClick(final Material mat, final Block block) {
|
private boolean isCanUseEntity_BothClick(final Material mat, final Block block) {
|
||||||
return mat == Material.LEVER || mat == Material.STONE_BUTTON || mat == Material.WOOD_BUTTON || mat == Material.WOODEN_DOOR || mat == Material.TRAP_DOOR || mat == Material.FENCE_GATE
|
return mat == Material.LEVER || mat == Material.STONE_BUTTON || mat == Material.WOOD_BUTTON || mat == Material.WOODEN_DOOR || mat == Material.TRAP_DOOR || mat == Material.FENCE_GATE
|
||||||
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG
|
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG || plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())
|
||||||
|| plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())
|
|| (plugin.isGt1_8() && (mat == Material.SPRUCE_DOOR || mat == Material.BIRCH_DOOR || mat == Material.JUNGLE_DOOR || mat == Material.ACACIA_DOOR || mat == Material.DARK_OAK_DOOR
|
||||||
|| (plugin.isGt1_8() && (mat == Material.SPRUCE_DOOR || mat == Material.BIRCH_DOOR || mat == Material.JUNGLE_DOOR || mat == Material.ACACIA_DOOR || mat == Material.DARK_OAK_DOOR
|
|| mat == Material.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE
|
||||||
|| mat == Material.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE
|
|| mat == Material.DARK_OAK_FENCE_GATE));
|
||||||
|| mat == Material.DARK_OAK_FENCE_GATE));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
|
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
|
||||||
return mat == Material.ITEM_FRAME || mat == Material.BEACON || mat == Material.FLOWER_POT || mat == Material.COMMAND || mat == Material.ANVIL || mat == Material.CAKE_BLOCK
|
return mat == Material.ITEM_FRAME || mat == Material.BEACON || mat == Material.FLOWER_POT || mat == Material.COMMAND || mat == Material.ANVIL || mat == Material.CAKE_BLOCK
|
||||||
|| mat == Material.NOTE_BLOCK || mat == Material.DIODE || mat == Material.DIODE_BLOCK_OFF || mat == Material.DIODE_BLOCK_ON || mat == Material.BED_BLOCK || mat == Material.WORKBENCH
|
|| mat == Material.NOTE_BLOCK || mat == Material.DIODE || mat == Material.DIODE_BLOCK_OFF || mat == Material.DIODE_BLOCK_ON || mat == Material.BED_BLOCK || mat == Material.WORKBENCH
|
||||||
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
|
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isContainer(final Material mat, final Block block) {
|
private boolean isContainer(final Material mat, final Block block) {
|
||||||
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|
||||||
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
|
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,9 +83,8 @@ public class PermissionManager {
|
|||||||
final String group = this.getPermissionsGroup(player, world);
|
final String group = this.getPermissionsGroup(player, world);
|
||||||
if (group == null || !groups.containsKey(group)) {
|
if (group == null || !groups.containsKey(group)) {
|
||||||
return plugin.getConfigManager().getDefaultGroup().toLowerCase();
|
return plugin.getConfigManager().getDefaultGroup().toLowerCase();
|
||||||
} else {
|
|
||||||
return group;
|
|
||||||
}
|
}
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionsGroup(final Player player) {
|
public String getPermissionsGroup(final Player player) {
|
||||||
@@ -121,9 +120,8 @@ public class PermissionManager {
|
|||||||
perms = vault;
|
perms = vault;
|
||||||
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
|
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
|
|
||||||
}
|
}
|
||||||
|
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package cn.citycraft.Residence.text;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,68 +16,67 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class Language {
|
public class Language {
|
||||||
public Map<String, String> text;
|
public Map<String, String> text;
|
||||||
|
|
||||||
public Language() {
|
public Language() {
|
||||||
text = new HashMap<String, String>();
|
text = new HashMap<String, String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String key, String intext) {
|
public static Language parseText(final FileConfiguration node, final String topkey) {
|
||||||
text.put(key, intext);
|
final Language newholder = new Language();
|
||||||
}
|
final Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
|
||||||
|
for (final String key : keys) {
|
||||||
|
newholder.text.put(key, node.getString(topkey + "." + key));
|
||||||
|
}
|
||||||
|
return newholder;
|
||||||
|
}
|
||||||
|
|
||||||
private String getText(String key) {
|
public String getPhrase(final String key) {
|
||||||
String t = text.get(key);
|
final String[] split = key.split("\\.");
|
||||||
if (t == null) {
|
return getPhrase(split);
|
||||||
t = "<missing language key: " + key + ">";
|
}
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPhrase(String key) {
|
public String getPhrase(final String key, final String words) {
|
||||||
String[] split = key.split("\\.");
|
return this.getPhrase(key.split("\\."), words);
|
||||||
return getPhrase(split);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getPhrase(String[] keys) {
|
public String getPhrase(final String[] keys) {
|
||||||
return this.getPhrase(keys, (String[]) null);
|
return this.getPhrase(keys, (String[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhrase(String key, String words) {
|
public String getPhrase(final String[] keys, final String words) {
|
||||||
return this.getPhrase(key.split("\\."), words);
|
if (words == null) {
|
||||||
}
|
return this.getPhrase(keys, (String[]) null);
|
||||||
|
}
|
||||||
|
return this.getPhrase(keys, words.split("\\."));
|
||||||
|
}
|
||||||
|
|
||||||
public String getPhrase(String[] keys, String words) {
|
public String getPhrase(final String[] keys, final String[] words) {
|
||||||
if (words == null) {
|
String sentence = "";
|
||||||
return this.getPhrase(keys, (String[]) null);
|
for (final String key : keys) {
|
||||||
} else {
|
if (sentence.length() == 0) {
|
||||||
return this.getPhrase(keys, words.split("\\."));
|
sentence = this.getText(key);
|
||||||
}
|
} else {
|
||||||
}
|
sentence = sentence + " " + this.getText(key).toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (words != null) {
|
||||||
|
for (int i = 0; i < words.length; i++) {
|
||||||
|
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sentence;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPhrase(String[] keys, String[] words) {
|
public void setText(final String key, final String intext) {
|
||||||
String sentence = "";
|
text.put(key, intext);
|
||||||
for (String key : keys) {
|
}
|
||||||
if (sentence.length() == 0) {
|
|
||||||
sentence = this.getText(key);
|
|
||||||
} else {
|
|
||||||
sentence = sentence + " " + this.getText(key).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (words != null) {
|
|
||||||
for (int i = 0; i < words.length; i++) {
|
|
||||||
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sentence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Language parseText(FileConfiguration node, String topkey) {
|
private String getText(final String key) {
|
||||||
Language newholder = new Language();
|
String t = text.get(key);
|
||||||
Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
|
if (t == null) {
|
||||||
for (String key : keys) {
|
t = "<missing language key: " + key + ">";
|
||||||
newholder.text.put(key, node.getString(topkey + "." + key));
|
}
|
||||||
}
|
return t;
|
||||||
return newholder;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,15 @@
|
|||||||
|
|
||||||
package cn.citycraft.Residence.vaultinterface;
|
package cn.citycraft.Residence.vaultinterface;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
import cn.citycraft.Residence.economy.EconomyInterface;
|
import cn.citycraft.Residence.economy.EconomyInterface;
|
||||||
import cn.citycraft.Residence.permissions.PermissionsInterface;
|
import cn.citycraft.Residence.permissions.PermissionsInterface;
|
||||||
|
import net.milkbowl.vault.chat.Chat;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -22,11 +21,11 @@ import cn.citycraft.Residence.permissions.PermissionsInterface;
|
|||||||
*/
|
*/
|
||||||
public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInterface {
|
public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInterface {
|
||||||
|
|
||||||
public static Permission permissions = null;
|
public static Permission permissions = null;
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
public static Chat chat = null;
|
public static Chat chat = null;
|
||||||
|
|
||||||
public ResidenceVaultAdapter(Server s) {
|
public ResidenceVaultAdapter(final Server s) {
|
||||||
this.setupPermissions(s);
|
this.setupPermissions(s);
|
||||||
this.setupEconomy(s);
|
this.setupEconomy(s);
|
||||||
this.setupChat(s);
|
this.setupChat(s);
|
||||||
@@ -34,13 +33,13 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean add(String playerName, double amount) {
|
public boolean add(final String playerName, final double amount) {
|
||||||
return economy.depositPlayer(playerName, amount).transactionSuccess();
|
return economy.depositPlayer(playerName, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean canAfford(String playerName, double amount) {
|
public boolean canAfford(final String playerName, final double amount) {
|
||||||
return economy.has(playerName, amount);
|
return economy.has(playerName, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public double getBalance(String playerName) {
|
public double getBalance(final String playerName) {
|
||||||
return economy.getBalance(playerName);
|
return economy.getBalance(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,22 +81,20 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerGroup(Player player) {
|
public String getPlayerGroup(final Player player) {
|
||||||
String group = permissions.getPrimaryGroup(player).toLowerCase();
|
final String group = permissions.getPrimaryGroup(player).toLowerCase();
|
||||||
if (group == null)
|
if (group == null)
|
||||||
return group;
|
return group;
|
||||||
else
|
return group.toLowerCase();
|
||||||
return group.toLowerCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String getPlayerGroup(String player, String world) {
|
public String getPlayerGroup(final String player, final String world) {
|
||||||
String group = permissions.getPrimaryGroup(world, player);
|
final String group = permissions.getPrimaryGroup(world, player);
|
||||||
if (group == null)
|
if (group == null)
|
||||||
return group;
|
return group;
|
||||||
else
|
return group.toLowerCase();
|
||||||
return group.toLowerCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean permissionsOK() {
|
public boolean permissionsOK() {
|
||||||
@@ -106,51 +103,45 @@ public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupChat(Server s) {
|
@SuppressWarnings("deprecation")
|
||||||
RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(
|
@Override
|
||||||
net.milkbowl.vault.chat.Chat.class);
|
public boolean subtract(final String playerName, final double amount) {
|
||||||
|
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||||
|
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
|
||||||
|
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
|
||||||
|
return true;
|
||||||
|
economy.depositPlayer(playerFrom, amount);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean setupChat(final Server s) {
|
||||||
|
final RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||||
if (chatProvider != null) {
|
if (chatProvider != null) {
|
||||||
chat = chatProvider.getProvider();
|
chat = chatProvider.getProvider();
|
||||||
}
|
}
|
||||||
return (chat != null);
|
return (chat != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupEconomy(Server s) {
|
private boolean setupEconomy(final Server s) {
|
||||||
RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager()
|
final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
.getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
||||||
if (economyProvider != null) {
|
if (economyProvider != null) {
|
||||||
economy = economyProvider.getProvider();
|
economy = economyProvider.getProvider();
|
||||||
}
|
}
|
||||||
return (economy != null);
|
return (economy != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupPermissions(Server s) {
|
private boolean setupPermissions(final Server s) {
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager()
|
final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||||
.getRegistration(net.milkbowl.vault.permission.Permission.class);
|
|
||||||
if (permissionProvider != null) {
|
if (permissionProvider != null) {
|
||||||
permissions = permissionProvider.getProvider();
|
permissions = permissionProvider.getProvider();
|
||||||
}
|
}
|
||||||
return (permissions != null);
|
return (permissions != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public boolean subtract(String playerName, double amount) {
|
|
||||||
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public boolean transfer(String playerFrom, String playerTo, double amount) {
|
|
||||||
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
|
|
||||||
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
|
|
||||||
return true;
|
|
||||||
else {
|
|
||||||
economy.depositPlayer(playerFrom, amount);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -88,9 +88,8 @@ public class Residence {
|
|||||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
return res.getPermissions();
|
return res.getPermissions();
|
||||||
} else {
|
|
||||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
|
||||||
}
|
}
|
||||||
|
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -27,8 +27,14 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
*/
|
*/
|
||||||
public class FlagPermissions {
|
public class FlagPermissions {
|
||||||
|
|
||||||
protected static ResidenceMain plugin;
|
public static enum FlagState {
|
||||||
|
FALSE,
|
||||||
|
INVALID,
|
||||||
|
NEITHER,
|
||||||
|
TRUE
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static ResidenceMain plugin;
|
||||||
protected static ArrayList<String> validAreaFlags = new ArrayList<String>();
|
protected static ArrayList<String> validAreaFlags = new ArrayList<String>();
|
||||||
protected static HashMap<String, ArrayList<String>> validFlagGroups = new HashMap<String, ArrayList<String>>();
|
protected static HashMap<String, ArrayList<String>> validFlagGroups = new HashMap<String, ArrayList<String>>();
|
||||||
protected static ArrayList<String> validFlags = new ArrayList<String>();
|
protected static ArrayList<String> validFlags = new ArrayList<String>();
|
||||||
@@ -37,6 +43,7 @@ public class FlagPermissions {
|
|||||||
protected Map<String, Boolean> cuboidFlags;
|
protected Map<String, Boolean> cuboidFlags;
|
||||||
protected Map<String, Map<String, Boolean>> groupFlags;
|
protected Map<String, Map<String, Boolean>> groupFlags;
|
||||||
protected FlagPermissions parent;
|
protected FlagPermissions parent;
|
||||||
|
|
||||||
protected Map<String, Map<String, Boolean>> playerFlags;
|
protected Map<String, Map<String, Boolean>> playerFlags;
|
||||||
|
|
||||||
public FlagPermissions() {
|
public FlagPermissions() {
|
||||||
@@ -457,9 +464,8 @@ public class FlagPermissions {
|
|||||||
sbuild.append("none");
|
sbuild.append("none");
|
||||||
}
|
}
|
||||||
return sbuild.toString();
|
return sbuild.toString();
|
||||||
} else {
|
|
||||||
return "none";
|
|
||||||
}
|
}
|
||||||
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String listOtherPlayersFlags(String player) {
|
public String listOtherPlayersFlags(String player) {
|
||||||
@@ -509,9 +515,8 @@ public class FlagPermissions {
|
|||||||
sbuild.append("none");
|
sbuild.append("none");
|
||||||
}
|
}
|
||||||
return sbuild.toString();
|
return sbuild.toString();
|
||||||
} else {
|
|
||||||
return "none";
|
|
||||||
}
|
}
|
||||||
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerHas(final String player, final String world, final String flag, final boolean def) {
|
public boolean playerHas(final String player, final String world, final String flag, final boolean def) {
|
||||||
@@ -627,11 +632,4 @@ public class FlagPermissions {
|
|||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum FlagState {
|
|
||||||
FALSE,
|
|
||||||
INVALID,
|
|
||||||
NEITHER,
|
|
||||||
TRUE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
|
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceCreationEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceCreationEvent;
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent;
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceRenameEvent;
|
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent.DeleteCause;
|
import com.bekvon.bukkit.residence.event.ResidenceDeleteEvent.DeleteCause;
|
||||||
|
import com.bekvon.bukkit.residence.event.ResidenceRenameEvent;
|
||||||
|
|
||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
import cn.citycraft.Residence.permissions.PermissionGroup;
|
import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||||
@@ -545,11 +545,13 @@ public class ResidenceManager {
|
|||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Total.Size") + ":" + ChatColor.LIGHT_PURPLE + " " + res.getTotalSize());
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Total.Size") + ":" + ChatColor.LIGHT_PURPLE + " " + res.getTotalSize());
|
||||||
if (aid != null) {
|
if (aid != null) {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsT") + ": " + ChatColor.LIGHT_PURPLE
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsT") + ": " + ChatColor.LIGHT_PURPLE
|
||||||
+ plugin.getLanguage().getPhrase("CoordsTop", res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX() + "."
|
+ plugin.getLanguage().getPhrase("CoordsTop",
|
||||||
+ res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockZ()));
|
res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockY() + "."
|
||||||
|
+ res.getAreaByLoc(player.getLocation()).getHighLoc().getBlockZ()));
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsB") + ": " + ChatColor.LIGHT_PURPLE
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("CoordsB") + ": " + ChatColor.LIGHT_PURPLE
|
||||||
+ plugin.getLanguage().getPhrase("CoordsBottom", res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "."
|
+ plugin.getLanguage().getPhrase("CoordsBottom",
|
||||||
+ res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ()));
|
res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockX() + "." + res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockY() + "."
|
||||||
|
+ res.getAreaByLoc(player.getLocation()).getLowLoc().getBlockZ()));
|
||||||
if (plugin.isUseWorldEdit()) {
|
if (plugin.isUseWorldEdit()) {
|
||||||
WECUI.UPDATESELECT(res, player);
|
WECUI.UPDATESELECT(res, player);
|
||||||
}
|
}
|
||||||
@@ -683,17 +685,15 @@ public class ResidenceManager {
|
|||||||
ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRename", ChatColor.YELLOW + oldName + ChatColor.GREEN + "." + ChatColor.YELLOW + newName + ChatColor.GREEN));
|
ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRename", ChatColor.YELLOW + oldName + ChatColor.GREEN + "." + ChatColor.YELLOW + newName + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
final String[] oldname = oldName.split("\\.");
|
|
||||||
final ClaimedResidence parent = res.getParent();
|
|
||||||
return parent.renameSubzone(player, oldname[oldname.length - 1], newName, resadmin);
|
|
||||||
}
|
}
|
||||||
} else {
|
final String[] oldname = oldName.split("\\.");
|
||||||
if (player != null) {
|
final ClaimedResidence parent = res.getParent();
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
return parent.renameSubzone(player, oldname[oldname.length - 1], newName, resadmin);
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
if (player != null) {
|
||||||
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean renameResidence(final String oldName, final String newName) {
|
public boolean renameResidence(final String oldName, final String newName) {
|
||||||
@@ -719,8 +719,7 @@ public class ResidenceManager {
|
|||||||
return worldmap;
|
return worldmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getResidenceList(final String targetplayer, final boolean showhidden, final boolean showsubzones, final String parentzone, final String resname, final ClaimedResidence res,
|
private void getResidenceList(final String targetplayer, final boolean showhidden, final boolean showsubzones, final String parentzone, final String resname, final ClaimedResidence res, final ArrayList<String> list, final boolean formattedOutput) {
|
||||||
final ArrayList<String> list, final boolean formattedOutput) {
|
|
||||||
final boolean hidden = res.getPermissions().has("hidden", false);
|
final boolean hidden = res.getPermissions().has("hidden", false);
|
||||||
if ((showhidden) || (!showhidden && !hidden)) {
|
if ((showhidden) || (!showhidden && !hidden)) {
|
||||||
if (targetplayer == null || res.getPermissions().getOwner().equalsIgnoreCase(targetplayer)) {
|
if (targetplayer == null || res.getPermissions().getOwner().equalsIgnoreCase(targetplayer)) {
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
|
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceFlagChangeEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceFlagChangeEvent;
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceFlagCheckEvent;
|
import com.bekvon.bukkit.residence.event.ResidenceFlagCheckEvent;
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceOwnerChangeEvent;
|
|
||||||
import com.bekvon.bukkit.residence.event.ResidenceFlagEvent.FlagType;
|
import com.bekvon.bukkit.residence.event.ResidenceFlagEvent.FlagType;
|
||||||
|
import com.bekvon.bukkit.residence.event.ResidenceOwnerChangeEvent;
|
||||||
|
|
||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
import cn.citycraft.Residence.permissions.PermissionGroup;
|
import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||||
@@ -260,9 +260,8 @@ public class ResidencePermissions extends FlagPermissions {
|
|||||||
final String renter = plugin.getRentManager().getRentingPlayer(resname);
|
final String renter = plugin.getRentManager().getRentingPlayer(resname);
|
||||||
if (player.getName().equalsIgnoreCase(renter)) {
|
if (player.getName().equalsIgnoreCase(renter)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return (playerHas(player.getName(), "admin", false));
|
|
||||||
}
|
}
|
||||||
|
return (playerHas(player.getName(), "admin", false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requireOwner) {
|
if (requireOwner) {
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ public class WorldFlagManager {
|
|||||||
if (list == null) {
|
if (list == null) {
|
||||||
if (globaldefaults == null) {
|
if (globaldefaults == null) {
|
||||||
return new FlagPermissions();
|
return new FlagPermissions();
|
||||||
} else {
|
|
||||||
return globaldefaults;
|
|
||||||
}
|
}
|
||||||
|
return globaldefaults;
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user