mirror of
https://e.coding.net/circlecloud/CityBuild.git
synced 2024-11-21 10:48:49 +00:00
使用PluginHelper和内部Residence...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
51400658c0
commit
6abc21083e
Binary file not shown.
63
pom.xml
63
pom.xml
@ -7,13 +7,10 @@
|
||||
<name>CityBuild</name>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
@ -25,30 +22,70 @@
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>cn.citycraft:PluginHelper</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>cn.citycraft.PluginHelper</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||
<update.description></update.description>
|
||||
<env.BUILD_NUMBER>1</env.BUILD_NUMBER>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citycraft-repo</id>
|
||||
<url>${jenkins.url}/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bekvon.bukkit.residence</groupId>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>PluginHelper</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<version>2.6.6.6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Residence.jar</systemPath>
|
||||
<type>jar</type>
|
||||
<version>2.8.1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
@ -1,55 +0,0 @@
|
||||
package cn.citycraft.CityBuild.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static String CONFIG_NAME = "config.yml";
|
||||
private static FileConfig instance;
|
||||
private static File file;
|
||||
|
||||
public Config(Plugin p) {
|
||||
super(p, CONFIG_NAME);
|
||||
file = new File(p.getDataFolder(), CONFIG_NAME);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public Config(Plugin p, String ver) {
|
||||
super(p, CONFIG_NAME, ver);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public static void load(Plugin p) {
|
||||
new Config(p);
|
||||
}
|
||||
|
||||
public static void load(Plugin p, String ver) {
|
||||
new Config(p, ver);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path);
|
||||
if (message != null)
|
||||
message = message.replaceAll("&", "§");
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String[] getStringArray(String path) {
|
||||
return instance.getStringList(path).toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static void save(){
|
||||
try {
|
||||
instance.save(file);
|
||||
} catch (IOException e) {
|
||||
saveError(file);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
package cn.citycraft.CityBuild.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class ConfigLoader extends FileConfig {
|
||||
protected static FileConfig config;
|
||||
protected static boolean tip = true;
|
||||
protected static Plugin plugin;
|
||||
|
||||
public ConfigLoader(Plugin p, File file) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, String ver) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, ver, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, String ver, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, ver, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null,
|
||||
true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, String ver) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, String ver, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public FileConfig loadConfig(Plugin p, File file, String ver, boolean res) {
|
||||
tip = res ;
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
p.getLogger().info("创建新的文件夹" + file.getParentFile().getAbsolutePath() + "...");
|
||||
}
|
||||
if (!file.exists()) {
|
||||
fileCreate(p, file, res);
|
||||
} else {
|
||||
if (ver != null) {
|
||||
FileConfig configcheck = init(file);
|
||||
String version = configcheck.getString("version");
|
||||
if (version == null || !version.equals(ver)) {
|
||||
p.saveResource(file.getName(), true);
|
||||
p.getLogger().warning(
|
||||
"配置文件: " + file.getName() + " 版本过低 正在升级...");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tip)
|
||||
p.getLogger().info(
|
||||
"载入配置文件: " + file.getName()
|
||||
+ (ver != null ? " 版本: " + ver : ""));
|
||||
return init(file);
|
||||
}
|
||||
|
||||
private void fileCreate(Plugin p, File file, boolean res) {
|
||||
if (res) {
|
||||
p.saveResource(file.getName(), false);
|
||||
} else {
|
||||
try {
|
||||
p.getLogger().info("创建新的配置文件" + file.getAbsolutePath() + "...");
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
p.getLogger().info("配置文件" + file.getName() + "创建失败...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveError(File file) {
|
||||
plugin.getLogger().info("配置文件" + file.getName() + "保存错误...");
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package cn.citycraft.CityBuild.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Data extends ConfigLoader {
|
||||
private static String CONFIG_NAME = "data.yml";
|
||||
private static FileConfig instance;
|
||||
private static File file;
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path);
|
||||
if (message != null) {
|
||||
message = message.replaceAll("&", "§");
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void load(Plugin p) {
|
||||
new Data(p);
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
instance.save(file);
|
||||
} catch (IOException e) {
|
||||
saveError(file);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Data(Plugin p) {
|
||||
super(p, CONFIG_NAME, false);
|
||||
file = new File(p.getDataFolder(), CONFIG_NAME);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package cn.citycraft.CityBuild.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConstructor;
|
||||
import org.bukkit.configuration.file.YamlRepresenter;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Configuration} which saves all files in Yaml.
|
||||
* Note that this implementation is not synchronized.
|
||||
*/
|
||||
public class FileConfig extends YamlConfiguration {
|
||||
|
||||
public static FileConfig init(File file) {
|
||||
return FileConfig.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public static FileConfig loadConfiguration(File file) {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
FileConfig config = new FileConfig();
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||
yamlRepresenter, yamlOptions);
|
||||
|
||||
@Override
|
||||
public void load(File file) throws FileNotFoundException, IOException,
|
||||
InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||
}
|
||||
@Override
|
||||
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||
BufferedReader input = (reader instanceof BufferedReader) ? (BufferedReader) reader
|
||||
: new BufferedReader(reader);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try {
|
||||
String line;
|
||||
while ((line = input.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append('\n');
|
||||
}
|
||||
} finally {
|
||||
input.close();
|
||||
}
|
||||
loadFromString(builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(File file) throws IOException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Files.createParentDirs(file);
|
||||
String data = saveToString();
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
||||
Charsets.UTF_8);
|
||||
try {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
String header = buildHeader();
|
||||
String dump = yaml.dump(getValues(false));
|
||||
if (dump.equals(BLANK_CONFIG)) {
|
||||
dump = "";
|
||||
}
|
||||
return header + dump;
|
||||
}
|
||||
}
|
@ -13,30 +13,31 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.CityBuild.config.Config;
|
||||
import cn.citycraft.CityBuild.config.Data;
|
||||
import cn.citycraft.CityBuild.listen.Build;
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
|
||||
public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
public FileConfig config;
|
||||
public FileConfig data;
|
||||
public Map<Location, String> mhl;
|
||||
public String servername;
|
||||
public String pluginname;
|
||||
public String servername;
|
||||
public boolean tipplayer;
|
||||
|
||||
public String getfullmsg(String path) {
|
||||
public String getfullmsg(final String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
return Config.getMessage(path);
|
||||
public String getmessage(final String path) {
|
||||
return config.getMessage(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
switch (args[0]) {
|
||||
case "reload":
|
||||
Data.save();
|
||||
data.save();
|
||||
onLoad();
|
||||
sender.sendMessage(getfullmsg("Message.Reload"));
|
||||
return true;
|
||||
@ -45,29 +46,27 @@ public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
if (mhl.isEmpty()) {
|
||||
sender.sendMessage(getfullmsg("Message.NotHave"));
|
||||
} else {
|
||||
for (Entry<Location, String> info : mhl.entrySet()) {
|
||||
String name = info.getValue();
|
||||
Location loc = info.getKey();
|
||||
World w = loc.getWorld();
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
sender.sendMessage(getfullmsg("Message.Info").replaceAll("%player%", name)
|
||||
.replaceAll("%world%", w.getName()).replaceAll("%x%", x + "")
|
||||
.replaceAll("%z%", z + ""));
|
||||
for (final Entry<Location, String> info : mhl.entrySet()) {
|
||||
final String name = info.getValue();
|
||||
final Location loc = info.getKey();
|
||||
final World w = loc.getWorld();
|
||||
final int x = loc.getBlockX();
|
||||
final int z = loc.getBlockZ();
|
||||
sender.sendMessage(getfullmsg("Message.Info").replaceAll("%player%", name).replaceAll("%world%", w.getName()).replaceAll("%x%", x + "").replaceAll("%z%", z + ""));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "clear":
|
||||
mhl.clear();
|
||||
Data.getInstance().set("MaxHeightList", null);
|
||||
Data.save();
|
||||
data.set("MaxHeightList", null);
|
||||
data.save();
|
||||
sender.sendMessage(getfullmsg("Message.NotHave"));
|
||||
return true;
|
||||
case "put":
|
||||
Player p = (Player) sender;
|
||||
final Player p = (Player) sender;
|
||||
mhl.put(p.getLocation(), p.getName());
|
||||
Data.getInstance().set("MaxHeightList", mhl);
|
||||
Data.save();
|
||||
data.set("MaxHeightList", mhl);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -75,8 +74,8 @@ public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Data.getInstance().set("MaxHeightList", mhl);
|
||||
Data.save();
|
||||
data.set("MaxHeightList", mhl);
|
||||
data.save();
|
||||
getLogger().info(pluginname + "城市世界建筑保护已卸载!");
|
||||
}
|
||||
|
||||
@ -89,14 +88,14 @@ public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Config.load(this, "1.1");
|
||||
Data.load(this);
|
||||
mhl = (Map<Location, String>) Config.getInstance().get("MaxHeightList");
|
||||
config = new FileConfig(this);
|
||||
data = new FileConfig("data.yml");
|
||||
mhl = (Map<Location, String>) config.get("MaxHeightList");
|
||||
if (mhl == null) {
|
||||
mhl = new HashMap<>();
|
||||
}
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname");
|
||||
tipplayer = Config.getInstance().getBoolean("tipplayer");
|
||||
tipplayer = config.getBoolean("tipplayer");
|
||||
}
|
||||
}
|
@ -12,47 +12,45 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import cn.citycraft.CityBuild.CityBuild;
|
||||
import cn.citycraft.CityBuild.config.Config;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
|
||||
import cn.citycraft.CityBuild.CityBuild;
|
||||
|
||||
public class Build implements Listener {
|
||||
|
||||
CityBuild plugin;
|
||||
|
||||
public Build(CityBuild main) {
|
||||
public Build(final CityBuild main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
// PlayerInteractEvent.class
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
public void blockBreak(final BlockBreakEvent event) {
|
||||
event.setCancelled(CancelEvent(event.getPlayer(), event.getBlock(), false));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockplace(BlockPlaceEvent event) {
|
||||
public void blockplace(final BlockPlaceEvent event) {
|
||||
event.setCancelled(CancelEvent(event.getPlayer(), event.getBlock(), true));
|
||||
}
|
||||
|
||||
public boolean CancelEvent(Player p, Block b, boolean place) {
|
||||
Location loc = b.getLocation();
|
||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
|
||||
public boolean CancelEvent(final Player p, final Block b, final boolean place) {
|
||||
final Location loc = b.getLocation();
|
||||
final ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
|
||||
if (res == null && !p.hasPermission("cb.build")) {
|
||||
String blockname = b.getType().name();
|
||||
World blockw = b.getWorld();
|
||||
int blockx = b.getX();
|
||||
int blocky = b.getY();
|
||||
int blockz = b.getZ();
|
||||
for (String protectworld : Config.getInstance().getStringList("ProtectWorld")) {
|
||||
final String blockname = b.getType().name();
|
||||
final World blockw = b.getWorld();
|
||||
final int blockx = b.getX();
|
||||
final int blocky = b.getY();
|
||||
final int blockz = b.getZ();
|
||||
for (final String protectworld : plugin.config.getStringList("ProtectWorld")) {
|
||||
if (protectworld.equalsIgnoreCase(blockw.getName())) {
|
||||
for (String allowblock : Config.getInstance().getStringList("AllowList")) {
|
||||
for (final String allowblock : plugin.config.getStringList("AllowList")) {
|
||||
if (blockname.equalsIgnoreCase(allowblock)) {
|
||||
for (String noticeblock : Config.getInstance().getStringList(
|
||||
"NoticeList")) {
|
||||
for (final String noticeblock : plugin.config.getStringList("NoticeList")) {
|
||||
if (blockname.equalsIgnoreCase(noticeblock) && place) {
|
||||
if (plugin.tipplayer) {
|
||||
p.getPlayer().sendMessage(plugin.getfullmsg("Message.Tip"));
|
||||
@ -60,32 +58,21 @@ public class Build implements Listener {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int maxheight = Config.getInstance().getInt("MaxHeight");
|
||||
final int maxheight = plugin.config.getInt("MaxHeight");
|
||||
if (blocky > maxheight && blockname.equalsIgnoreCase("Dirt")) {
|
||||
if (plugin.tipplayer) {
|
||||
p.getPlayer().sendMessage(
|
||||
plugin.getfullmsg("Message.Max").replaceAll(
|
||||
"%maxheight%", maxheight + ""));
|
||||
p.getPlayer().sendMessage(plugin.getfullmsg("Message.Max").replaceAll("%maxheight%", maxheight + ""));
|
||||
}
|
||||
Bukkit.broadcast(
|
||||
plugin.getfullmsg("Message.Notice1")
|
||||
.replaceAll("%player%", p.getDisplayName())
|
||||
.replaceAll("%maxheight%", maxheight + ""),
|
||||
Bukkit.broadcast(plugin.getfullmsg("Message.Notice1").replaceAll("%player%", p.getDisplayName()).replaceAll("%maxheight%", maxheight + ""), "cb.notice");
|
||||
Bukkit.broadcast(plugin.getfullmsg("Message.Notice2").replaceAll("%world%", blockw.getName()).replaceAll("%x%", blockx + "").replaceAll("%z%", blockz + ""),
|
||||
"cb.notice");
|
||||
Bukkit.broadcast(
|
||||
plugin.getfullmsg("Message.Notice2")
|
||||
.replaceAll("%world%", blockw.getName())
|
||||
.replaceAll("%x%", blockx + "")
|
||||
.replaceAll("%z%", blockz + ""), "cb.notice");
|
||||
plugin.mhl.put(loc, p.getName());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String[] message = { plugin.getfullmsg("Message.Wran"),
|
||||
plugin.getfullmsg("Message.Allow"),
|
||||
plugin.getfullmsg("Message.Relieve") };
|
||||
final String[] message = { plugin.getfullmsg("Message.Wran"), plugin.getfullmsg("Message.Allow"), plugin.getfullmsg("Message.Relieve") };
|
||||
if (plugin.tipplayer) {
|
||||
p.getPlayer().sendMessage(message);
|
||||
}
|
||||
@ -96,13 +83,13 @@ public class Build implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean CancelEvent(Player p, Material m) {
|
||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(p.getLocation());
|
||||
public boolean CancelEvent(final Player p, final Material m) {
|
||||
final ClaimedResidence res = Residence.getResidenceManager().getByLoc(p.getLocation());
|
||||
if (res == null && !p.hasPermission("cb.build")) {
|
||||
String blockname = m.name();
|
||||
for (String protectworld : Config.getInstance().getStringList("ProtectWorld")) {
|
||||
final String blockname = m.name();
|
||||
for (final String protectworld : plugin.config.getStringList("ProtectWorld")) {
|
||||
if (protectworld.equalsIgnoreCase(p.getWorld().getName())) {
|
||||
for (String notallowblock : Config.getInstance().getStringList("NotAllowList")) {
|
||||
for (final String notallowblock : plugin.config.getStringList("NotAllowList")) {
|
||||
if (blockname.equalsIgnoreCase(notallowblock)) {
|
||||
if (plugin.tipplayer) {
|
||||
p.getPlayer().sendMessage(plugin.getfullmsg("Message.NotAllow"));
|
||||
@ -117,7 +104,7 @@ public class Build implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void playerInteract(PlayerInteractEvent event) {
|
||||
public void playerInteract(final PlayerInteractEvent event) {
|
||||
event.setCancelled(CancelEvent(event.getPlayer(), event.getMaterial()));
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
name: CityBuild
|
||||
main: cn.citycraft.CityBuild.CityBuild
|
||||
version: 1.1
|
||||
name: ${project.artifactId}
|
||||
description: ${project.description}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||
version: ${project.version}-Build#${env.BUILD_NUMBER}
|
||||
author: 喵♂呜
|
||||
website: ${jenkins.url}/job/${project.artifactId}/
|
||||
depend: [Residence]
|
||||
commands:
|
||||
cb:
|
Loading…
Reference in New Issue
Block a user