mirror of
https://e.coding.net/circlecloud/SimpleProtect.git
synced 2024-11-22 01:49:03 +00:00
rebuild priject...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
315459159e
commit
a68f7cbefa
@ -17,12 +17,15 @@ public class SimpleProtect extends JavaPlugin {
|
||||
public String servername;
|
||||
public String pluginname;
|
||||
|
||||
public void onLoad() {
|
||||
Config.load(this, "1.0");
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname");
|
||||
public String getfullmsg(String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
return Config.getMessage(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("==========" + servername + pluginname + "==========");
|
||||
|
||||
@ -59,12 +62,11 @@ public class SimpleProtect extends JavaPlugin {
|
||||
getLogger().info("==========" + servername + pluginname + "==========");
|
||||
}
|
||||
|
||||
public String getfullmsg(String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
return Config.getMessage(path);
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Config.load(this, "1.0");
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,15 +30,9 @@ import com.google.common.io.Files;
|
||||
*/
|
||||
public class FileConfig extends YamlConfiguration {
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||
yamlRepresenter, yamlOptions);
|
||||
|
||||
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();
|
||||
@ -52,6 +46,34 @@ public class FileConfig extends YamlConfiguration {
|
||||
}
|
||||
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 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() {
|
||||
@ -65,24 +87,4 @@ public class FileConfig extends YamlConfiguration {
|
||||
}
|
||||
return header + dump;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,33 @@ public class HighRedstone implements Runnable, Listener {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedClock(BlockRedstoneEvent event) {
|
||||
Block rb = event.getBlock();
|
||||
if (rb.getType() == Material.REDSTONE_WIRE) {
|
||||
put(event.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
private void put(Block block) {
|
||||
if (map.containsKey(block)) {
|
||||
int i = map.remove(block);
|
||||
map.put(block, i + 1);
|
||||
} else {
|
||||
map.put(block, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void RedStonePlace(BlockPlaceEvent event) {
|
||||
Block rb = event.getBlock();
|
||||
Player rp = event.getPlayer();
|
||||
if (rb.getType() == Material.REDSTONE_WIRE) {
|
||||
pmap.put(rb, rp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
for (Entry<Block, Integer> entry : map.entrySet()) {
|
||||
@ -61,7 +88,7 @@ public class HighRedstone implements Runnable, Listener {
|
||||
if (rp != null) {
|
||||
Bukkit.broadcastMessage(plugin.getfullmsg(
|
||||
"HighRedstone.Check").replaceAll("%player%",
|
||||
rp.getName()));
|
||||
rp.getName()));
|
||||
pmap.remove(block);
|
||||
}
|
||||
tip = !tip;
|
||||
@ -70,30 +97,4 @@ public class HighRedstone implements Runnable, Listener {
|
||||
}
|
||||
map.clear();
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void RedStonePlace(BlockPlaceEvent event) {
|
||||
Block rb = event.getBlock();
|
||||
Player rp = event.getPlayer();
|
||||
if (rb.getType() == Material.REDSTONE_WIRE) {
|
||||
pmap.put(rb, rp);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedClock(BlockRedstoneEvent event) {
|
||||
Block rb = event.getBlock();
|
||||
if (rb.getType() == Material.REDSTONE_WIRE) {
|
||||
put(event.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
private void put(Block block) {
|
||||
if (map.containsKey(block)) {
|
||||
int i = map.remove(block);
|
||||
map.put(block, i + 1);
|
||||
} else {
|
||||
map.put(block, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -28,6 +31,7 @@ public class NetherDoor implements Listener {
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Player p = e.getPlayer();
|
||||
Location loc = p.getLocation();
|
||||
|
@ -18,17 +18,18 @@ public class Tip implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
plugin.getServer().getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
public void run() {
|
||||
Player p = e.getPlayer();
|
||||
String[] msg = Config.getStringArray("Tip.Message");
|
||||
for (String s : msg) {
|
||||
s = s.replaceAll("&", "§");
|
||||
p.sendMessage(plugin.servername + plugin.pluginname
|
||||
+ s);
|
||||
}
|
||||
}
|
||||
}, 15);
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player p = e.getPlayer();
|
||||
String[] msg = Config.getStringArray("Tip.Message");
|
||||
for (String s : msg) {
|
||||
s = s.replaceAll("&", "§");
|
||||
p.sendMessage(plugin.servername + plugin.pluginname
|
||||
+ s);
|
||||
}
|
||||
}
|
||||
}, 15);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user