Skip to content

Commit

Permalink
clean some mechanisms
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 6, 2019
1 parent 3904d3c commit 5fac080
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 44 deletions.
Expand Up @@ -42,8 +42,6 @@ private BungeePlayerExtension(dPlayer player) {
@Override
public void adjust(Mechanism mechanism) {

Element value = mechanism.getValue();

// <--[mechanism]
// @object dPlayer
// @name send_to
Expand All @@ -57,7 +55,7 @@ public void adjust(Mechanism mechanism) {
if (mechanism.matches("send_to")
&& mechanism.requireObject(dServer.class)) {
if (BungeeSupport.isSocketRegistered()) {
Packet packet = new ClientPacketOutSendPlayer(player.getName(), value.asType(dServer.class).getName());
Packet packet = new ClientPacketOutSendPlayer(player.getName(), mechanism.getValue().asType(dServer.class).getName());
BungeeSupport.getSocketClient().trySend(packet);
}
else {
Expand Down
Expand Up @@ -75,8 +75,6 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();

// <--[mechanism]
// @object dItem
// @name worth
Expand All @@ -88,9 +86,9 @@ public void adjust(Mechanism mechanism) {
// <i@item.worth.quantity[<Element>]>
// @Plugin DepenizenBukkit, Essentials
// -->
if (mechanism.matches("worth") && value.isDouble()) {
if (mechanism.matches("worth") && mechanism.getValue().isDouble()) {
Essentials ess = Support.getPlugin(EssentialsSupport.class);
ess.getWorth().setPrice(ess, item.getItemStack(), value.asDouble());
ess.getWorth().setPrice(ess, item.getItemStack(), mechanism.getValue().asDouble());
}

}
Expand Down
Expand Up @@ -234,8 +234,6 @@ public String getAttribute(Attribute attribute) {
@Override
public void adjust(Mechanism mechanism) {

Element value = mechanism.getValue();

// <--[mechanism]
// @object dPlayer
// @name is_afk
Expand All @@ -247,7 +245,7 @@ public void adjust(Mechanism mechanism) {
// @Plugin DepenizenBukkit, Essentials
// -->
if ((mechanism.matches("afk") || mechanism.matches("is_afk")) && mechanism.requireBoolean()) {
getUser().setAfk(value.asBoolean());
getUser().setAfk(mechanism.getValue().asBoolean());
}

// <--[mechanism]
Expand All @@ -261,7 +259,7 @@ public void adjust(Mechanism mechanism) {
// @Plugin DepenizenBukkit, Essentials
// -->
if (mechanism.matches("god_mode") && mechanism.requireBoolean()) {
getUser().setGodModeEnabled(value.asBoolean());
getUser().setGodModeEnabled(mechanism.getValue().asBoolean());
}

// <--[mechanism]
Expand All @@ -277,8 +275,8 @@ public void adjust(Mechanism mechanism) {
// @Plugin DepenizenBukkit, Essentials
// -->
if ((mechanism.matches("muted") || mechanism.matches("is_muted")) && mechanism.requireBoolean()) {
if (value.asString().length() > 0) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2);
if (mechanism.getValue().asString().length() > 0) {
String[] split = mechanism.getValue().asString().split("[\\|" + dList.internal_escape + "]", 2);
if (split.length > 0 && new Element(split[0]).isBoolean()) {
getUser().setMuted(new Element(split[0]).asBoolean());
if (split.length > 1 && Duration.matches(split[1])) {
Expand All @@ -303,7 +301,7 @@ public void adjust(Mechanism mechanism) {
// @Plugin DepenizenBukkit, Essentials
// -->
if (mechanism.matches("socialspy") && mechanism.requireBoolean()) {
getUser().setSocialSpyEnabled(value.asBoolean());
getUser().setSocialSpyEnabled(mechanism.getValue().asBoolean());
}

// <--[mechanism]
Expand All @@ -317,7 +315,7 @@ public void adjust(Mechanism mechanism) {
// @Plugin DepenizenBukkit, Essentials
// -->
if (mechanism.matches("vanish") && mechanism.requireBoolean()) {
getUser().setVanished(value.asBoolean());
getUser().setVanished(mechanism.getValue().asBoolean());
}


Expand All @@ -333,15 +331,15 @@ public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("essentials_ignore")) {
Essentials essentials = Support.getPlugin(EssentialsSupport.class);
if (value.asString().contains("|")) {
int split = value.asString().indexOf("|");
int len = value.asString().length();
String after = value.asString().substring(split + 1, len);
String before = value.asString().substring(0, split - 1);
if (mechanism.getValue().asString().contains("|")) {
int split = mechanism.getValue().asString().indexOf("|");
int len = mechanism.getValue().asString().length();
String after = mechanism.getValue().asString().substring(split + 1, len);
String before = mechanism.getValue().asString().substring(0, split - 1);
getUser().setIgnoredPlayer(essentials.getUser(new Element(before).asType(dPlayer.class).getOfflinePlayer().getUniqueId()), new Element(after).asBoolean());
}
else {
getUser().setIgnoredPlayer(essentials.getUser(value.asType(dPlayer.class).getOfflinePlayer().getUniqueId()), true);
getUser().setIgnoredPlayer(essentials.getUser(mechanism.getValue().asType(dPlayer.class).getOfflinePlayer().getUniqueId()), true);
}
}

Expand Down
Expand Up @@ -98,6 +98,5 @@ else if (attribute.startsWith("claim")) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -142,14 +142,12 @@ else if (attribute.startsWith("total")) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();

if (mechanism.matches("bonus_blocks") && mechanism.requireInteger()) {
data.setBonusClaimBlocks(value.asInt());
data.setBonusClaimBlocks(mechanism.getValue().asInt());
}

if (mechanism.matches("normal_blocks") && mechanism.requireInteger()) {
data.setAccruedClaimBlocks(value.asInt());
data.setAccruedClaimBlocks(mechanism.getValue().asInt());
}
}
}
Expand Up @@ -76,7 +76,6 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}

Expand Up @@ -64,6 +64,5 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -64,6 +64,5 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -69,6 +69,5 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -64,6 +64,5 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -69,6 +69,5 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -81,6 +81,5 @@ public String getAttribute(Attribute attribute) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -127,6 +127,5 @@ else if (attribute.startsWith("active")) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}
Expand Up @@ -192,8 +192,6 @@ else if (attribute.startsWith("can_siege") && attribute.hasContext(1)) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();

// <--[mechanism]
// @object GriefPreventionClaim
// @name owner
Expand All @@ -206,11 +204,11 @@ public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("owner")) {
try {
if (dPlayer.matches(value.asString())) {
dPlayer player = dPlayer.valueOf(value.asString());
if (dPlayer.matches(mechanism.getValue().asString())) {
dPlayer player = dPlayer.valueOf(mechanism.getValue().asString());
dataStore.changeClaimOwner(claim, player.getOfflinePlayer().getUniqueId());
}
else if (CoreUtilities.toLowerCase(value.asString()).equals("admin")) {
else if (CoreUtilities.toLowerCase(mechanism.getValue().asString()).equals("admin")) {
dataStore.changeClaimOwner(claim, null);
}
}
Expand All @@ -229,7 +227,7 @@ else if (CoreUtilities.toLowerCase(value.asString()).equals("admin")) {
// None
// -->
if (mechanism.matches("depth") && mechanism.requireInteger()) {
dataStore.extendClaim(claim, value.asInt());
dataStore.extendClaim(claim, mechanism.getValue().asInt());
}

// Iterate through this object's properties' mechanisms
Expand Down
Expand Up @@ -279,8 +279,6 @@ else if (attribute.startsWith("type")) {

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();

// <--[mechanism]
// @object MythicMob
// @name global_cooldown
Expand All @@ -291,7 +289,7 @@ public void adjust(Mechanism mechanism) {
// <mythicmob@mythicmob.global_cooldown>
// -->
if (mechanism.matches("global_cooldown") && mechanism.requireInteger()) {
mob.setGlobalCooldown(value.asInt());
mob.setGlobalCooldown(mechanism.getValue().asInt());
}

// <--[mechanism]
Expand All @@ -317,7 +315,7 @@ else if (mechanism.matches("reset_target")) {
// <mythicmob@mythicmob.target>
// -->
else if (mechanism.matches("target") && mechanism.requireObject(dEntity.class)) {
dEntity mTarget = dEntity.valueOf(value.asString());
dEntity mTarget = dEntity.valueOf(mechanism.getValue().asString());
if (mTarget == null || !mTarget.isValid() || mTarget.getLivingEntity() == null) {
return;
}
Expand Down

0 comments on commit 5fac080

Please sign in to comment.