Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
antiRedstoneClock
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Trafalcraft
antiRedstoneClock
Commits
4f26918a
Commit
4f26918a
authored
Oct 22, 2016
by
Amosar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small optimisation/remove debuguer
parent
a82203b2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
34 deletions
+25
-34
src/com/trafalcraft/antiRedstoneClock/Main.java
src/com/trafalcraft/antiRedstoneClock/Main.java
+6
-6
src/com/trafalcraft/antiRedstoneClock/PlayerListener.java
src/com/trafalcraft/antiRedstoneClock/PlayerListener.java
+4
-5
src/com/trafalcraft/antiRedstoneClock/object/RedstoneClock.java
...m/trafalcraft/antiRedstoneClock/object/RedstoneClock.java
+5
-9
src/com/trafalcraft/antiRedstoneClock/object/RedstoneClockController.java
...aft/antiRedstoneClock/object/RedstoneClockController.java
+2
-6
src/com/trafalcraft/antiRedstoneClock/util/CustomConfig.java
src/com/trafalcraft/antiRedstoneClock/util/CustomConfig.java
+8
-8
No files found.
src/com/trafalcraft/antiRedstoneClock/Main.java
View file @
4f26918a
...
...
@@ -28,8 +28,8 @@ public class Main extends JavaPlugin{
private
String
line3
;
private
String
line4
;
private
static
ArrayList
<
String
>
ignoreWorld
=
new
ArrayList
<
String
>();
private
static
ArrayList
<
String
>
ignoreRegion
=
new
ArrayList
<
String
>();
private
static
final
ArrayList
<
String
>
ignoreWorld
=
new
ArrayList
<
>();
private
static
final
ArrayList
<
String
>
ignoreRegion
=
new
ArrayList
<
>();
public
void
onEnable
(){
long
startTime
=
System
.
currentTimeMillis
();
...
...
@@ -118,7 +118,7 @@ public class Main extends JavaPlugin{
private
static
void
checkTimer
(
int
delay
){
Bukkit
.
getScheduler
().
scheduleSyncRepeatingTask
(
instance
,
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
RedstoneClock
brdc
:
RedstoneClockController
.
getAll
()){
...
...
@@ -205,7 +205,7 @@ public class Main extends JavaPlugin{
}
}
else
if
(
args
[
0
].
equalsIgnoreCase
(
"notifyAdmin"
)){
if
(
args
.
length
==
1
){
if
(
getConfig
().
getBoolean
(
"NotifyAdmins"
)
==
true
){
if
(
getConfig
().
getBoolean
(
"NotifyAdmins"
)){
getConfig
().
set
(
"NotifyAdmins"
,
false
);
saveConfig
();
sender
.
sendMessage
(
CustomConfig
.
Prefix
+
CustomConfig
.
newValueInConfig
.
toString
().
replace
(
"$setting"
,
"\"NotifyAdmins\""
).
replace
(
"$value"
,
"false"
));
...
...
@@ -215,11 +215,11 @@ public class Main extends JavaPlugin{
sender
.
sendMessage
(
CustomConfig
.
Prefix
+
CustomConfig
.
newValueInConfig
.
toString
().
replace
(
"$setting"
,
"\"NotifyAdmins\""
).
replace
(
"$value"
,
"true"
));
}
}
else
{
if
(
Boolean
.
parseBoolean
(
args
[
1
])
==
true
){
if
(
Boolean
.
parseBoolean
(
args
[
1
])){
getConfig
().
set
(
"NotifyAdmins"
,
true
);
saveConfig
();
sender
.
sendMessage
(
CustomConfig
.
Prefix
+
CustomConfig
.
newValueInConfig
.
toString
().
replace
(
"$setting"
,
"\"NotifyAdmins\""
).
replace
(
"$value"
,
args
[
1
]));
}
else
if
(
Boolean
.
parseBoolean
(
args
[
1
])==
false
){
}
else
if
(
!
Boolean
.
parseBoolean
(
args
[
1
])
){
getConfig
().
set
(
"NotifyAdmins"
,
false
);
saveConfig
();
sender
.
sendMessage
(
CustomConfig
.
Prefix
+
CustomConfig
.
newValueInConfig
.
toString
().
replace
(
"$setting"
,
"\"NotifyAdmins\""
).
replace
(
"$value"
,
args
[
1
]));
...
...
src/com/trafalcraft/antiRedstoneClock/PlayerListener.java
View file @
4f26918a
...
...
@@ -66,13 +66,12 @@ public class PlayerListener implements Listener {
}
RedstoneClockController
.
removeRedstoneByLocation
(
e
.
getBlock
().
getLocation
());
}
else
{
System
.
out
.
println
(
RedstoneClockController
.
getRedstoneClock
(
e
.
getBlock
().
getLocation
()).
getBoucle
());
RedstoneClockController
.
getRedstoneClock
(
e
.
getBlock
().
getLocation
()).
addBoucle
();
}
}
}
}
}
else
if
(
e
.
getBlock
().
getType
()
==
Material
.
DIODE_BLOCK_ON
||
e
.
getBlock
().
getType
()
==
Material
.
REDSTONE_COMPARATOR_ON
){
...
...
@@ -93,7 +92,7 @@ public class PlayerListener implements Listener {
e
.
getBlock
().
setType
(
Material
.
AIR
);
}
Bukkit
.
getScheduler
().
scheduleSyncDelayedTask
(
Main
.
getInstance
(),
new
Runnable
()
{
@Override
public
void
run
()
{
b
.
setType
(
Material
.
SIGN_POST
);
...
...
@@ -121,10 +120,10 @@ public class PlayerListener implements Listener {
}
}
}
}
/* @EventHandler (priority = EventPriority.LOWEST)
public void onRedstoneClock2(BlockPhysicsEvent e){
System.out.println(e.getBlock().getType());
...
...
src/com/trafalcraft/antiRedstoneClock/object/RedstoneClock.java
View file @
4f26918a
...
...
@@ -6,14 +6,14 @@ import com.trafalcraft.antiRedstoneClock.Main;
public
class
RedstoneClock
{
private
long
endTime
;
private
final
long
endTime
;
private
int
boucle
;
private
Location
loc
;
private
final
Location
loc
;
//only for comparator
private
boolean
lastStatus
;
public
RedstoneClock
(
Location
loc
){
endTime
=
(
long
)
System
.
currentTimeMillis
()
/
1000
+
Main
.
getDelay
();
endTime
=
System
.
currentTimeMillis
()
/
1000
+
Main
.
getDelay
();
boucle
=
0
;
this
.
loc
=
loc
;
//only for comparator
...
...
@@ -38,11 +38,7 @@ public class RedstoneClock {
//only for comparator
public
void
updateStatus
(){
if
(
lastStatus
){
lastStatus
=
false
;
}
else
{
lastStatus
=
true
;
}
lastStatus
=
!
lastStatus
;
}
//only for comparator
public
boolean
getlastStatus
(){
...
...
@@ -50,6 +46,6 @@ public class RedstoneClock {
}
public
boolean
isEnd
(){
return
(
(
long
)
System
.
currentTimeMillis
()
/
1000
)>=
endTime
;
return
(
System
.
currentTimeMillis
()
/
1000
)>=
endTime
;
}
}
src/com/trafalcraft/antiRedstoneClock/object/RedstoneClockController.java
View file @
4f26918a
...
...
@@ -11,22 +11,18 @@ import com.trafalcraft.antiRedstoneClock.util.CustomConfig;
public
class
RedstoneClockController
{
//private static Map<Location, RedstoneClock> activeMap = Maps.newHashMap();
private
static
ConcurrentMap
<
Location
,
RedstoneClock
>
activeMap
=
Maps
.
newConcurrentMap
();
private
static
final
ConcurrentMap
<
Location
,
RedstoneClock
>
activeMap
=
Maps
.
newConcurrentMap
();
public
static
void
addRedstone
(
Location
location
)
throws
Exception
{
if
(
contains
(
location
)){
throw
new
Exception
(
CustomConfig
.
ERREUR
+
CustomConfig
.
duplicate_object
.
toString
());
}
else
{
activeMap
.
put
(
location
,
new
RedstoneClock
(
location
));
return
;
}
}
public
static
boolean
contains
(
Location
location
){
if
(
activeMap
.
containsKey
(
location
)){
return
true
;
}
return
false
;
return
activeMap
.
containsKey
(
location
);
}
public
static
void
removeRedstoneByLocation
(
Location
location
){
...
...
src/com/trafalcraft/antiRedstoneClock/util/CustomConfig.java
View file @
4f26918a
...
...
@@ -23,15 +23,15 @@ public enum CustomConfig {
//Exception
duplicate_object
(
"This list already contains this redstone"
);
static
JavaPlugin
plugin
=
Main
.
getInstance
();
static
final
JavaPlugin
plugin
=
Main
.
getInstance
();
public
static
void
getHelp
(
Player
sender
){
sender
.
sendMessage
(
""
);
sender
.
sendMessage
(
"§3§l-------------AntiRedstoneClock-------------"
);
sender
.
sendMessage
(
"§3/arc checkList <
nom de l'arene
> §b- display the active redstoneclock."
);
sender
.
sendMessage
(
"§3/arc setMaxImpulsion <num
ero
> §b- Change the 0\"MaxImpulsion\" setting."
);
sender
.
sendMessage
(
"§3/arc setDelay <num
ero
> §b- Change the \"Delay\" setting."
);
sender
.
sendMessage
(
"§3/arc notifyAdmin <num
ero
> §b- change the \"notifyAdmin\" setting."
);
sender
.
sendMessage
(
"§3/arc reload <num
ero
> §b- To reload the config file."
);
sender
.
sendMessage
(
"§3/arc checkList <
Page number
> §b- display the active redstoneclock."
);
sender
.
sendMessage
(
"§3/arc setMaxImpulsion <num
ber
> §b- Change the 0\"MaxImpulsion\" setting."
);
sender
.
sendMessage
(
"§3/arc setDelay <num
ber
> §b- Change the \"Delay\" setting."
);
sender
.
sendMessage
(
"§3/arc notifyAdmin <num
ber
> §b- change the \"notifyAdmin\" setting."
);
sender
.
sendMessage
(
"§3/arc reload <num
ber
> §b- To reload the config file."
);
sender
.
sendMessage
(
" §3Version: §6"
+
plugin
.
getDescription
().
getVersion
());
sender
.
sendMessage
(
"§3------------------------------------------------"
);
sender
.
sendMessage
(
""
);
...
...
@@ -40,14 +40,14 @@ public enum CustomConfig {
private
String
value
;
private
CustomConfig
(
String
value
)
{
CustomConfig
(
String
value
)
{
this
.
value
=
value
;
}
public
String
toString
(){
return
value
;
}
p
ublic
void
replaceby
(
String
value
){
p
rivate
void
replaceby
(
String
value
){
this
.
value
=
value
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment