本文整理匯總了Java中org.bukkit.event.player.PlayerGameModeChangeEvent.getNewGameMode方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerGameModeChangeEvent.getNewGameMode方法的具體用法?Java PlayerGameModeChangeEvent.getNewGameMode怎麽用?Java PlayerGameModeChangeEvent.getNewGameMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerGameModeChangeEvent
的用法示例。
在下文中一共展示了PlayerGameModeChangeEvent.getNewGameMode方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onGamemodeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event){
GameMode newMode = event.getNewGameMode();
String worldName = event.getPlayer().getWorld().getName();
if(!event.getPlayer().hasPermission("spigotplus.gamemode." + worldName + "." + newMode)){
boolean modeFound = false;
for(GameMode mode : GameMode.values()){
if(event.getPlayer().hasPermission("spigotplus.gamemode." + worldName + "." + mode)){
modeFound = true;
break;
}
}
event.setCancelled(true);
event.getPlayer().sendMessage("You are not permitted to use the " + newMode + " gamemode in this world");
if(!modeFound){
logWarn("The player " + event.getPlayer().getName() + " is not permitted to use any gamemode in the world \"" + worldName + "\"");
event.getPlayer().kickPlayer("There is a configuration error with the gamemodes you are permitted to use. Please contact the server administrator");
}
}
}
示例2: onPlayerGameModeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer();
GameMode oldGameMode = player.getGameMode();
GameMode newGameMode = event.getNewGameMode();
Group group = plugin.getGroupManager().getGroupFromWorld(player.getWorld().getName());
if (group == null) {
group = new Group(player.getWorld().getName(), null, null);
}
plugin.getSerializer().writePlayerDataToFile(player,
PlayerSerialization.serializePlayer(player, plugin),
group,
oldGameMode);
plugin.getSerializer().getPlayerDataFromFile(
player,
group,
newGameMode);
}
示例3: onGameModeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGameModeChange(PlayerGameModeChangeEvent event) {
GameMode gameMode = event.getPlayer().getGameMode();
// check if we switch to survival from an exempt GameMode and update.
if (Arc.COMPATIBILITY) {
if ((gameMode == GameMode.CREATIVE && event.getNewGameMode() == GameMode.SURVIVAL)) {
MovingData.getData(event.getPlayer()).setLastGameModeChange(System.currentTimeMillis());
}
} else {
if ((gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR) && event.getNewGameMode() == GameMode.SURVIVAL) {
MovingData.getData(event.getPlayer()).setLastGameModeChange(System.currentTimeMillis());
}
}
}
示例4: onChangeGM
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onChangeGM(PlayerGameModeChangeEvent e) {
Player p = e.getPlayer();
UUID pU = e.getPlayer().getUniqueId();
int GamemodeTemp1 = 0;
if (e.getNewGameMode() == GameMode.SURVIVAL) {
GamemodeTemp1 = 0;
} else if (e.getNewGameMode() == GameMode.CREATIVE) {
GamemodeTemp1 = 1;
} else if (e.getNewGameMode() == GameMode.ADVENTURE) {
GamemodeTemp1 = 2;
} else if (e.getNewGameMode() == GameMode.SPECTATOR) {
GamemodeTemp1 = 3;
}
int GamemodeTemp2 = Integer.valueOf(GamemodeTemp1);
if (!ConfigTemp.getConfig().contains(String.valueOf(pU))) {
ConfigTemp.getConfig().set(pU+".Player", String.valueOf(p));
ConfigTemp.getConfig().set(pU+".Options.Gamemode", Integer.valueOf(GamemodeTemp2));
ConfigTemp.saveConfigFile();
} else if (ConfigTemp.getConfig().contains(String.valueOf(pU))) {
ConfigTemp.getConfig().set(pU+".Player", String.valueOf(p));
ConfigTemp.getConfig().set(pU+".Options.Gamemode", Integer.valueOf(GamemodeTemp2));
ConfigTemp.saveConfigFile();
}
}
示例5: onGameModeSwitch
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGameModeSwitch(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
if (event.getNewGameMode() == GameMode.CREATIVE) {
InventoryLocker.unlockSlots(player);
} else if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
InventoryLocker.lockSlots(player, true);
}
}
示例6: gameModeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void gameModeChange(final PlayerGameModeChangeEvent event) {
Optional<User> optionalUser = UserManager.getInstance().getUser(event.getPlayer().getUniqueId());
User user = optionalUser.orElseGet(() -> new User(event.getPlayer(), Participation.SPECTATOR));
if (event.getPlayer().isOp() || event.getNewGameMode() == GameMode.CREATIVE) {
user.setParticipation(Participation.ADMIN);
} else {
user.setParticipation(Participation.PARTICIPATOR);
}
UserManager.getInstance().addUser(user);
}
示例7: onGamemodeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event)
{
Player player = event.getPlayer();
if (event.getNewGameMode() != GameMode.CREATIVE || Thirst.getInstance().getYAMLConfig().ignoreCreative)
{
ThirstManager.getThirst().displayThirst(player);
return;
}
else if (event.getNewGameMode() == GameMode.CREATIVE && !Thirst.getInstance().getYAMLConfig().ignoreCreative)
{
for (PotionEffect effect : player.getActivePotionEffects())
{
player.removePotionEffect(effect.getType());
}
}
if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("scoreboard"))
{
if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("SCOREBOARD"))
player.setScoreboard(Bukkit.getServer().getScoreboardManager().getNewScoreboard());
}
else if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("action"))
{
UtilActionBar.getInstance().sendActionBar(player, "");
}
else if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("bossbar"))
{
ThirstData data = ThirstManager.getThirst().getThirstData(player);
if (data.getBar() != null)
{
data.getBar().removePlayer(player);
}
}
}
示例8: onGameModeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onGameModeChange(PlayerGameModeChangeEvent e) {
Player p = e.getPlayer();
if (playerStateInfoMap.containsKey(p) && e.getNewGameMode() != GameMode.SPECTATOR) {
// Don't let low-priority event listeners cancel the gamemode change
if (e.isCancelled()) e.setCancelled(false);
}
}
示例9: onPlayerGamemodeChanged
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerGamemodeChanged(PlayerGameModeChangeEvent evt) {
InventoryKey beforeKey = new InventoryKey(evt.getPlayer().getUniqueId(), getGroupName(evt
.getPlayer().getWorld().getName()), evt.getPlayer().getGameMode());
InventoryKey afterKey = new InventoryKey(evt.getPlayer().getUniqueId(), getGroupName(evt
.getPlayer().getWorld().getName()), evt.getNewGameMode());
if (!beforeKey.equals(afterKey)) {
switchInventory(beforeKey, afterKey);
}
}
示例10: gamemodeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void gamemodeChange(PlayerGameModeChangeEvent event){
BTPlayer ply;
try{
ply = pdata.getBTPlayer(event.getPlayer());
}
catch (UnknownBTPlayerException e){
return;
}
if(event.getNewGameMode() != GameMode.CREATIVE && ply.isBuildModeActive()){
ply.setBuildModeActive(false);
ply.sendMessage("Build mode deactivated.", ChatColor.RED);
}
}
示例11: onGameMode
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGameMode(PlayerGameModeChangeEvent e) {
if(e.getNewGameMode() == GameMode.CREATIVE) {
if(staff.containsKey(e.getPlayer().getName())) {
Bukkit.getScheduler().cancelTask(staff.get(e.getPlayer().getName()));
staff.remove(e.getPlayer().getName());
sendMessage(e.getPlayer(), ChatColor.GRAY + "teleportation safety against damage has been " + ChatColor.RED + "worn off");
}
}
}
示例12: onGamemodeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
/**
* Used to prevent spectators from changing their gamemode whilst spectating.
*/
@EventHandler(priority=EventPriority.HIGHEST)
public void onGamemodeChange(final PlayerGameModeChangeEvent e)
{
final Spectator spectator = p.getPlayerData(e.getPlayer());
if (spectator.isSpectating() && e.getNewGameMode() != GameMode.ADVENTURE && !spectator.isGamemodeChangeAllowed())
{
e.setCancelled(true);
e.getPlayer().setAllowFlight(true);
}
}
示例13: onPlayerGameModeChange
import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerGameModeChange(final PlayerGameModeChangeEvent event) {
if (event.getNewGameMode() == GameMode.CREATIVE) {
this.tracker.cancelFall(event.getPlayer());
}
}