Hey ich hab nen Plugin angefangen was zensieren und Welt Begrenzung setzten kann, allerdings funktioniert es noch nicht und ich weiß leider nicht wo der Fehler liegt
Der Zensur Teil ist mir dabei nicht ganz so wichtig also wenn ihr mir da nicht helfen könnt ist es nicht schlimm die Weltbegrenzung wäre mir allerdings sehr wichtig
hoffe auf Hilfe
Das hier ist die main:
Das hier sind die Events:
Das hier ist die main:
Javascript:
package me.reschiram.main;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class main extends JavaPlugin{
ArrayList<String> blacklist = new ArrayList<String>();
public void onEnable(){
new events(this);
File file = new File (this.getDataFolder() + "\\blacklist.txt");
try {
Scanner s= new Scanner(file);
while(s.hasNextLine()){
blacklist.add(s.nextLine());
}
s.close();
} catch (FileNotFoundException e) {
System.err.println("keine blacklist.txt gefunden!");
}
}
public File f = new File("plugins/reschiramworks", "locs.yml");
public FileConfiguration cfg = YamlConfiguration.loadConfiguration(f);
public void setLocation(Location loc, Integer Radius) {
String w = loc.getWorld().getName();
cfg.set(w+".world" ,w);
cfg.set(w + ".x",loc.getBlockX());
cfg.set(w + ".y",loc.getBlockY());
cfg.set(w + ".z",loc.getBlockZ());
cfg.set(w + ".Radius", Radius);
try {
cfg.save(f);
} catch (IOException e) {
}
}
public Location getLoc(World w) {
World wa = Bukkit.getWorld(cfg.getString(w + ".world"));
return new Location(wa, cfg.getDouble(w.getName() + ".x"), cfg.getDouble(w.getName() + ".y"), cfg.getDouble(w.getName() + ".z"));
}
public Integer getr(World w){
return new Integer (cfg.getInt(w.getName()+ ".Radius"));
}
public boolean onCommand(CommandSender sender, Command cmd,
String label, String[] args){
Player p = null;
if(sender instanceof Player){
p = (Player) sender;
}
events ev = new events(this);
if(cmd.getName().equalsIgnoreCase("createwall")){
if(args.length == 1){
if(p.hasPermission("A.s")){
if(!cfg.contains(p.getWorld().getName())){
try{
setLocation( p.getLocation(), Integer.parseInt(args[0]));
ev.Locations.put(p.getWorld(), p.getLocation());
ev.distance.put(((World)p.getWorld()),Integer.parseInt(args[0]));
}catch(NullPointerException e){
}
return true;
}else {
}
}
}
}
return false;
}
}
Das hier sind die Events:
Javascript:
@EventHandler
public void onMove(PlayerMoveEvent e){
Player p = e.getPlayer();
for(int x = 0; x< Igs.size(); x++){
if(Igs.get(x).getTarget() != p){
Igs.get(x).setTarget(p);
}
}
if(plugin.getConfig().contains(p.getWorld().getName())){
Locations.put(p.getWorld(), plugin.getLoc(p.getWorld()));
distance.put(p.getWorld(), plugin.getr(p.getWorld()));
}
if(Locations.containsValue(p.getWorld()) ){
Location loc = p.getLocation();
Location m = Locations.get(p.getWorld());
int d = distance.get(p.getWorld());
if(m.distance(loc) >= d){
int AX = m.getBlockX();
int AY = m.getBlockY();
int AZ = m.getBlockZ();
int BX = loc.getBlockX();
int BY = loc.getBlockY();
int BZ = loc.getBlockZ();
int X = AX-BX;
int Y = AY-BY;
int Z = AZ-BZ;
Vector vector = new Vector(X, Y, Z ).normalize();
vector.multiply(0.8D);
vector.setY(0.5D);
p.setVelocity(vector);
p.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 4);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent e){
String msg = e.getMessage();
int m = 0;
String nmsg = new String();
for(int a = 1; a<plugin.blacklist.size(); a++){
if(msg.contains(plugin.blacklist.get(a))){
nmsg=plugin.blacklist.get(0);
m = 1;
}
}
if(m == 0){
e.setMessage(msg);
}else if (m== 1){
e.setMessage(nmsg);
m = 0;
}
}