WorldEditShortcuts #115
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
|
|
||||||
import com.sk89q.worldedit.command.WorldEditCommands;
|
|
||||||
import de.steamwar.bausystem.commands.*;
|
import de.steamwar.bausystem.commands.*;
|
||||||
import de.steamwar.bausystem.commands.worldedit.*;
|
import de.steamwar.bausystem.commands.worldedit.*;
|
||||||
import de.steamwar.bausystem.tracer.ShowManager;
|
import de.steamwar.bausystem.tracer.ShowManager;
|
||||||
@ -68,14 +67,14 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
String worldName = Bukkit.getWorlds().get(0).getName();
|
String worldName = Bukkit.getWorlds().get(0).getName();
|
||||||
try{
|
try {
|
||||||
owner = UUID.fromString(worldName);
|
owner = UUID.fromString(worldName);
|
||||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + getOwner().toString() + "/sections.yml"));
|
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + getOwner().toString() + "/sections.yml"));
|
||||||
}catch(IllegalArgumentException e){
|
} catch (IllegalArgumentException e) {
|
||||||
try{
|
try {
|
||||||
owner = null;
|
owner = null;
|
||||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + worldName + "/sections.yml"));
|
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + worldName + "/sections.yml"));
|
||||||
}catch(IOException | InvalidConfigurationException ex){
|
} catch (IOException | InvalidConfigurationException ex) {
|
||||||
getLogger().log(Level.SEVERE, "owner is no UUID / failed to load sections.yml", e);
|
getLogger().log(Level.SEVERE, "owner is no UUID / failed to load sections.yml", e);
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
return;
|
return;
|
||||||
@ -141,25 +140,28 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
|
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BauSystem getPlugin(){
|
public static BauSystem getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
public static UUID getOwner(){
|
|
||||||
|
public static UUID getOwner() {
|
||||||
//Lazy loading to improve startup time of the server in 1.15
|
//Lazy loading to improve startup time of the server in 1.15
|
||||||
if(owner == null){
|
if (owner == null) {
|
||||||
try{
|
try {
|
||||||
owner = SteamwarUser.get(Integer.parseInt(Bukkit.getWorlds().get(0).getName())).getUUID();
|
owner = SteamwarUser.get(Integer.parseInt(Bukkit.getWorlds().get(0).getName())).getUUID();
|
||||||
}catch(NumberFormatException e){
|
} catch (NumberFormatException e) {
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
throw new SecurityException("owner is not a UserID", e);
|
throw new SecurityException("owner is not a UserID", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
public static List<ArenaSection> getSections(){
|
|
||||||
|
public static List<ArenaSection> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
public static int getOwnerID(){
|
|
||||||
|
public static int getOwnerID() {
|
||||||
return SteamwarUser.get(getOwner()).getId();
|
return SteamwarUser.get(getOwner()).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +172,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerLoginEvent e) {
|
public void onJoin(PlayerLoginEvent e) {
|
||||||
if(autoShutdown != null){
|
if (autoShutdown != null) {
|
||||||
autoShutdown.cancel();
|
autoShutdown.cancel();
|
||||||
autoShutdown = null;
|
autoShutdown = null;
|
||||||
}
|
}
|
||||||
@ -192,37 +194,37 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
ItemStack stack = e.getCursor();
|
ItemStack stack = e.getCursor();
|
||||||
if (stack == null || !stack.hasItemMeta())
|
if (stack == null || !stack.hasItemMeta())
|
||||||
return;
|
return;
|
||||||
assert stack.getItemMeta() != null;
|
assert stack.getItemMeta() != null;
|
||||||
if (stack.getItemMeta().hasEnchants()) {
|
if (stack.getItemMeta().hasEnchants()) {
|
||||||
for (Enchantment en : Enchantment.values()) {
|
for (Enchantment en : Enchantment.values()) {
|
||||||
if (stack.getEnchantmentLevel(en) > en.getMaxLevel())
|
if (stack.getEnchantmentLevel(en) > en.getMaxLevel())
|
||||||
stack.removeEnchantment(en);
|
stack.removeEnchantment(en);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = stack.getType();
|
Material material = stack.getType();
|
||||||
if (material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION) {
|
if (material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION) {
|
||||||
stack.setType(Material.MILK_BUCKET);
|
stack.setType(Material.MILK_BUCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core.getVersion() < 14) {
|
if (Core.getVersion() < 14) {
|
||||||
e.setCurrentItem(stack);
|
e.setCurrentItem(stack);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getItemMeta().hasAttributeModifiers()) {
|
if (stack.getItemMeta().hasAttributeModifiers()) {
|
||||||
ItemMeta meta = stack.getItemMeta();
|
ItemMeta meta = stack.getItemMeta();
|
||||||
for (Attribute a : Attribute.values()) {
|
for (Attribute a : Attribute.values()) {
|
||||||
meta.removeAttributeModifier(a);
|
meta.removeAttributeModifier(a);
|
||||||
}
|
}
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
e.setCurrentItem(stack);
|
e.setCurrentItem(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren