Skip to content

Commit

Permalink
他pluginに影響がでる不具合を修正、コードを一新
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-Ideal committed Dec 21, 2024
1 parent a01c0b2 commit 21c3369
Show file tree
Hide file tree
Showing 19 changed files with 299 additions and 308 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.Shin_Ideal</groupId>
<artifactId>LobbyFlyPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0.0</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package com.github.Shin_Ideal.LobbyFlyPlugin.CommandExecutors;

import com.github.Shin_Ideal.LobbyFlyPlugin.LobbyFlyPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Fly implements CommandExecutor {
public class FlyCommandExecutor implements CommandExecutor {

private final LobbyFlyPlugin Instance;

public FlyCommandExecutor() {
Instance = LobbyFlyPlugin.getInstance();
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
player.setAllowFlight(!player.getAllowFlight());
player.sendMessage(Instance.getPluginMessagePrefix() + "Fly is " + (player.getAllowFlight() ? ChatColor.GREEN + "enable" : ChatColor.RED + "disable"));
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package com.github.Shin_Ideal.LobbyFlyPlugin.CommandExecutors;

import com.github.Shin_Ideal.LobbyFlyPlugin.ConfigManager;
import com.github.Shin_Ideal.LobbyFlyPlugin.ListenerManager;
import com.github.Shin_Ideal.LobbyFlyPlugin.LobbyFlyPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class FlyManage implements CommandExecutor {
public class FlyManageCommandExecutor implements CommandExecutor {

private final LobbyFlyPlugin Instance;

public FlyManageCommandExecutor() {
Instance = LobbyFlyPlugin.getInstance();
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(args.length==0){
if (args.length == 0) {
sendHelp(sender);
return true;
}else {
switch (args[0]){
} else {
switch (args[0]) {
case "help":
sendHelp(sender);
break;

case "reload":
reload();
sender.sendMessage("reloaded!");
reload(sender);
break;

default:
Expand All @@ -32,14 +36,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}

private void sendHelp(CommandSender sender){
private void sendHelp(CommandSender sender) {
sender.sendMessage("/flymanage <help>");
sender.sendMessage("/flymanage <reload>");
}

private void reload() {
ConfigManager.reload();
ListenerManager.reload();
private void reload(CommandSender sender) {
Instance.reloadConfig();
sender.sendMessage(Instance.getPluginMessagePrefix() + "Config Reloaded!");
}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.Shin_Ideal.LobbyFlyPlugin.Listeners;

import com.github.Shin_Ideal.LobbyFlyPlugin.LobbyFlyPlugin;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;

public class BackFromVoidListener implements Listener {

private final LobbyFlyPlugin Instance;
private final Configuration config;

public BackFromVoidListener() {
Instance = LobbyFlyPlugin.getInstance();
config = Instance.getConfig();
}

@EventHandler
public void onDamage(EntityDamageEvent event) {
if (!config.getBoolean("back-from-void.enable")) {
return;
}

if (!(event.getEntity() instanceof Player)) {
return;
}
if (!event.getCause().equals(EntityDamageEvent.DamageCause.VOID)) {
return;
}
Player player = (Player) event.getEntity();
player.teleport(player.getWorld().getSpawnLocation().add(
config.getDouble("join-tp-spawn.add-x")
, config.getDouble("join-tp-spawn.add-y")
, config.getDouble("join-tp-spawn.add-z")
));
event.setCancelled(true);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.Shin_Ideal.LobbyFlyPlugin.Listeners;

import com.github.Shin_Ideal.LobbyFlyPlugin.LobbyFlyPlugin;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;

public class DisableAllDamageListener implements Listener {

private final LobbyFlyPlugin Instance;
private final Configuration config;

public DisableAllDamageListener() {
Instance = LobbyFlyPlugin.getInstance();
config = Instance.getConfig();
}

@EventHandler
public void onDamage(EntityDamageEvent event) {
if (!config.getBoolean("disable-all-damage.enable")) {
return;
}

if (!(event.getEntity() instanceof Player)) {
return;
}

event.setCancelled(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.github.Shin_Ideal.LobbyFlyPlugin.Listeners;

import com.github.Shin_Ideal.LobbyFlyPlugin.LobbyFlyPlugin;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;

public class DisableFallDamageListener implements Listener {

private final LobbyFlyPlugin Instance;
private final Configuration config;

public DisableFallDamageListener() {
Instance = LobbyFlyPlugin.getInstance();
config = Instance.getConfig();
}

@EventHandler
public void onDamage(EntityDamageEvent event) {
if (!config.getBoolean("disable-fall-damage.enable")) {
return;
}

if (!(event.getEntity() instanceof Player)) {
return;
}
if (!event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) {
return;
}

event.setCancelled(true);
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 21c3369

Please sign in to comment.