-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from huda0209/master
[add]opがついた状態でswitchしても適切に権限が切り替わる機能を追加
- Loading branch information
Showing
8 changed files
with
148 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
src/main/java/com/github/mori01231/aziswitch/NewSwitchGroupCommandExecutor.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
src/main/java/com/github/mori01231/aziswitch/PlayerJoinEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.mori01231.aziswitch; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
|
||
import java.util.List; | ||
|
||
public class PlayerJoinEventListener implements Listener { | ||
private final String pluginName = AziSwitch.getInstance().getDescription().getPrefix(); | ||
private final String servername = configManager.getServerName(); | ||
private List<String> singleServerGroups; | ||
private List<String> allServerGroups; | ||
private List<String> OPs; | ||
|
||
@EventHandler | ||
public void PlayerJoinEventHandler(PlayerJoinEvent event){ | ||
OPs = configManager.getOPs(); | ||
Player player = event.getPlayer(); | ||
if(!OPs.contains(String.valueOf(player.getUniqueId())) ) return; | ||
|
||
singleServerGroups = configManager.getSingleServerGroups(); | ||
allServerGroups = configManager.getAllServerGroups(); | ||
|
||
Boolean hasGroup = false; | ||
for(String group : singleServerGroups) if(player.hasPermission("aziswitch.is" + group + " server=" + servername)) hasGroup = true; | ||
for(String group : allServerGroups) if(player.hasPermission("aziswitch.is" + group)) hasGroup = true; | ||
if(!hasGroup) return; | ||
|
||
OPs.remove(String.valueOf(player.getUniqueId())); | ||
configManager.setOPs(OPs); | ||
player.setOp(true); | ||
sendPlayerMessage(player,"&4OP&3を&a付与&3しました。"); | ||
} | ||
|
||
public void sendPlayerMessage(Player player, String message){ | ||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',"&7[&b"+pluginName+"&7]&r "+message )); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/github/mori01231/aziswitch/configManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.github.mori01231.aziswitch; | ||
|
||
import org.bukkit.configuration.Configuration; | ||
|
||
|
||
import java.util.List; | ||
|
||
public class configManager { | ||
private static AziSwitch plugin = AziSwitch.getInstance(); | ||
private static Configuration config = plugin.getConfig(); | ||
private static String servername; | ||
private static List<String> singleServerGroups; | ||
private static List<String> allServerGroups; | ||
private static List<String> OPs; | ||
|
||
|
||
public static void loadConfig(){ | ||
servername = config.getString("lp-server-name"); | ||
singleServerGroups = config.getStringList("SingleServerGroups"); | ||
allServerGroups = config.getStringList("AllServerGroups"); | ||
OPs = config.getStringList("OPs"); | ||
} | ||
|
||
public static String getServerName(){ | ||
return servername; | ||
} | ||
|
||
public static List<String> getSingleServerGroups(){ | ||
return singleServerGroups; | ||
} | ||
|
||
public static List<String> getAllServerGroups(){ | ||
return allServerGroups; | ||
} | ||
|
||
public static List<String> getOPs(){ | ||
return OPs; | ||
} | ||
|
||
public static void setSingleServerGroups(List<String> Lists){ | ||
singleServerGroups = Lists; | ||
config.set("SingleServerGroups", singleServerGroups); | ||
} | ||
|
||
public static void setAllServerGroups(List<String> Lists){ | ||
allServerGroups = Lists; | ||
config.set("AllServerGroups", allServerGroups); | ||
} | ||
|
||
public static void setOPs(List<String> Lists){ | ||
OPs = Lists; | ||
config.set("OPs", OPs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,6 @@ AllServerGroups: | |
- owner | ||
- developer | ||
- alladmin | ||
|
||
# op状態でswitchを実行した人を保存(触るな) | ||
OPs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters