Skip to content

Commit

Permalink
[VoteUp] 添加了新功能.
Browse files Browse the repository at this point in the history
- 为 Autocast 功能添加了新的处理模式.
  - 现在将配置文件中的 BlackMode 设置为 true 将视为黑名单模式.
  - 同理, 设置为 false 将视为白名单模式.

本次 Commit 还包含以下改动:
[LimitRiptide]
- 修复了一个可能的刷物品 Bug.
  - 对该 Bug 的解决方案可能导致在某些情况下的无损激流飞行, 但是情况过于极限所以暂不作处理.
  • Loading branch information
Polar-Pumpkin committed Feb 28, 2020
1 parent 96d0369 commit 88504bf
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 26 deletions.
13 changes: 13 additions & 0 deletions .idea/libraries/Maven__net_md_5_bungeecord_chat_1_15_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_yaml_snakeyaml_1_25.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions LimitedRiptide/LimitedRiptide.iml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
</component>
</module>
6 changes: 3 additions & 3 deletions LimitedRiptide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>net.shoal.sir</groupId>
<artifactId>LitmiedRiptide</artifactId>
<version>1.5-RELEASE</version>
<artifactId>LimitedRiptide</artifactId>
<version>1.6-RELEASE</version>
<packaging>jar</packaging>

<name>LimitedRiptide</name>
Expand Down Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,36 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
@EventHandler
public void onInteract(PlayerRiptideEvent event) {

if(glidingPlayers == null) {
if (glidingPlayers == null) {
locale.debug("&e&lWARN! &7Gliding player log lost, recreated.");
glidingPlayers = new HashMap<>();
}

locale.debug("&7PlayerRiptideEvent activated: (&aPlayer&7) &c" + event.getPlayer().getName());
PlayerInventory userInv = event.getPlayer().getInventory();
ItemStack trident = event.getItem();
ItemStack trident = event.getItem().clone();
locale.debug("&7Item information: " + trident.toString());
boolean isMainHand = userInv.getItemInMainHand().getType() == Material.TRIDENT;
boolean isMainHand;
if (trident.getType() == Material.TRIDENT) {
ItemStack mainHand = userInv.getItemInMainHand();
ItemStack offHand = userInv.getItemInOffHand();
if (mainHand.getType() == Material.TRIDENT) {
isMainHand = true;
} else if (offHand.getType() == Material.TRIDENT) {
isMainHand = false;
} else {
return;
}
} else {
return;
}
locale.debug("&7Is trident in main hand? " + (isMainHand ? "&a&lYes" : "&c&lNo"));
boolean isGliding = glidingPlayers.getOrDefault(event.getPlayer(), false);
locale.debug("&7Is player flying with Elytra? " + (isGliding ? "&a&lYes" : "&c&lNo&7(Or missing log&7)"));
ItemMeta itemMeta = trident.getItemMeta();
locale.debug("&7Is target trident's ItemMeta null? " + (itemMeta == null ? "&a&lYes" : "&c&lNo"));
Damageable meta = (Damageable) (itemMeta == null ? Bukkit.getItemFactory().getItemMeta(Material.TRIDENT) : itemMeta);
if(meta != null) {
if (meta != null) {
int resultDurability = meta.getDamage() + (isGliding ? config.getInt("DurabilityCost.Flying") : config.getInt("DurabilityCost.Normal"));
locale.debug("&7After reducing the durability value is: &c&l" + resultDurability);

Expand All @@ -155,6 +168,7 @@ public void onInteract(PlayerRiptideEvent event) {
sendItem(userInv, new ItemStack(Material.AIR), isMainHand);
locale.debug("&7Trident has been broken.");
}

} else {
locale.debug("&c&lERROR! &7After validating, ItemMeta still was null!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

public class LocaleUtil {

@Getter @Setter private String defaultLocaleKey = "Chinese";
@Getter
@Setter
private String defaultLocaleKey = "English";
private Plugin plugin;
private File dataFolder;
@Getter private Map<String, FileConfiguration> locales = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion LimitedRiptide/src/main/resources/Locales/Chinese.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Plugin:
WARN: "&e&l>> "
ERROR: "&c&l>> "
HelpMessage:
- "&9&lLimited Riptide &8&o(v1.4-RELEASE)"
- "&9&lLimited Riptide &8&o(v1.5-RELEASE)"
- ""
- "&7&l作者: &cEntityParrot_"
- "&7&l命令列表:"
Expand Down
2 changes: 1 addition & 1 deletion LimitedRiptide/src/main/resources/Locales/English.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Plugin:
WARN: "&e&l>> "
ERROR: "&c&l>> "
HelpMessage:
- "&9&lLimited Riptide &8&o(v1.4-RELEASE)"
- "&9&lLimited Riptide &8&o(v1.5-RELEASE)"
- ""
- "&7&lAuthor: &cEntityParrot_"
- "&7&lCommand List:"
Expand Down
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>net.shoal.sir</groupId>
<artifactId>VoteUp</artifactId>
<version>1.4-RELEASE</version>
<version>1.4.1-RELEASE</version>
<packaging>jar</packaging>

<name>VoteUp</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ protected Prompt acceptValidatedInput(ConversationContext context, String input)

if(type == VoteDataType.AUTOCAST) {
String[] inputArgs = input.split(" ");
List<String> blacklist = VoteUp.getInstance().getConfig().getStringList("Autocast.Blacklist");
for(String arg : inputArgs) {
if(blacklist.contains(arg)) {
if(user.hasPermission(VoteUpPerm.CREATE_CUSTOM_AUTOCAST_BYPASS.perm())) {
continue;
List<String> commandList = VoteUp.getInstance().getConfig().getStringList("Autocast.List");
boolean blackMode = VoteUp.getInstance().getConfig().getBoolean("Autocast.BlackMode");
if (blackMode) {
if (commandList.contains(inputArgs[0])) {
if (!user.hasPermission(VoteUpPerm.CREATE_CUSTOM_AUTOCAST_BYPASS.perm())) {
CommonUtil.message(locale.buildMessage(VoteUp.LOCALE, MessageType.WARN, "&7您输入的命令中含有屏蔽关键词."), user.getName());
return Prompt.END_OF_CONVERSATION;
}
}
} else {
if (!commandList.contains(inputArgs[0])) {
if (!user.hasPermission(VoteUpPerm.CREATE_CUSTOM_AUTOCAST_BYPASS.perm())) {
CommonUtil.message(locale.buildMessage(VoteUp.LOCALE, MessageType.WARN, "&7您输入的命令中含有屏蔽关键词."), user.getName());
return Prompt.END_OF_CONVERSATION;
}
CommonUtil.message(locale.buildMessage(VoteUp.LOCALE, MessageType.WARN, "&7您输入的命令中含有屏蔽关键词."), user.getName());
return Prompt.END_OF_CONVERSATION;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Sound:
End: BLOCK_ANVIL_HIT
Autocast:
Enable: true
Blacklist:
BlackMode: true
List:
- "op"
- "gamemode"
- "gm"
Expand Down

0 comments on commit 88504bf

Please sign in to comment.