Created
March 6, 2020 03:23
-
-
Save SocraticPhoenix/f1942d4e39b6a1e101669a1c6f56b997 to your computer and use it in GitHub Desktop.
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
package com.gmail.socraticphoenix.testplugin; | |
import org.spongepowered.api.entity.living.player.Player; | |
import org.spongepowered.api.event.Listener; | |
import org.spongepowered.api.event.filter.cause.First; | |
import org.spongepowered.api.event.filter.type.Include; | |
import org.spongepowered.api.event.item.inventory.InteractItemEvent; | |
import org.spongepowered.api.plugin.Plugin; | |
import org.spongepowered.api.text.Text; | |
import org.spongepowered.api.text.format.TextColor; | |
import org.spongepowered.api.text.format.TextColors; | |
import java.util.Random; | |
@Plugin(id = "testdatafirstlogin") | |
public class TestPlugin { | |
private static Random random = new Random(); | |
@Listener | |
@Include({InteractItemEvent.Primary.class, InteractItemEvent.Secondary.class}) | |
public void onClickItem(InteractItemEvent event, @First Player player) { | |
TextColor[] colors = new TextColor[]{TextColors.GOLD, TextColors.GREEN, TextColors.AQUA, TextColors.BLUE, TextColors.YELLOW}; | |
String type; | |
if (event instanceof InteractItemEvent.Primary) { | |
type = "primary"; | |
} else { | |
type = "secondary"; | |
} | |
event.setCancelled(true); | |
player.sendMessage(Text.of(colors[random.nextInt(colors.length)], type)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment